You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

etherboot.prefix.lds 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
  2. OUTPUT_ARCH(i386)
  3. ENTRY(_prefix_start)
  4. SECTIONS {
  5. /* Prefix */
  6. .prefix : {
  7. _verbatim_start = . ;
  8. _prefix_start = . ;
  9. *(.prefix)
  10. . = ALIGN(16);
  11. _prefix_end = . ;
  12. } = 0x9090
  13. _prefix_size = _prefix_end - _prefix_start;
  14. .text.nocompress : {
  15. *(.prefix.udata)
  16. } = 0x9090
  17. decompress_to = . ;
  18. .prefix.zdata : {
  19. _compressed = . ;
  20. *(.prefix.zdata)
  21. _compressed_end = . ;
  22. }
  23. _compressed_size = _compressed_end - _compressed;
  24. . = ALIGN(16);
  25. _verbatim_end = . ;
  26. /* Size of the core of etherboot in memory */
  27. _base_size = _end - _text;
  28. /* _prefix_size is the length of the non-core etherboot prefix */
  29. _prefix_size = _prefix_end - _prefix_start;
  30. /* _verbatim_size is the actual amount that has to be copied to base memory */
  31. _verbatim_size = _verbatim_end - _verbatim_start;
  32. /* _image_size is the amount of base memory needed to run */
  33. _image_size = _base_size + _prefix_size;
  34. /* Standard sizes rounded up to paragraphs */
  35. _prefix_size_pgh = (_prefix_size + 15) / 16;
  36. _verbatim_size_pgh = (_verbatim_size + 15) / 16;
  37. _image_size_pgh = (_image_size + 15) / 16 ;
  38. /* Standard sizes in sectors */
  39. _prefix_size_sct = (_prefix_size + 511) / 512;
  40. _verbatim_size_sct = (_verbatim_size + 511) / 512;
  41. _image_size_sct = (_image_size + 511) / 512;
  42. /* Symbol offsets and sizes for the exe prefix */
  43. _exe_hdr_size = 32;
  44. _exe_size = _verbatim_size; /* Should this be - 32 to exclude the header? */
  45. _exe_size_tail = (_exe_size) % 512;
  46. _exe_size_pages = ((_exe_size) + 511) / 512;
  47. _exe_bss_size = ((_image_size - _verbatim_size) + 15) / 16;
  48. _exe_ss_offset = (_stack_offset + _prefix_size - _exe_hdr_size + 15) / 16 ;
  49. /* This is where we copy the compressed image before decompression.
  50. * Prepare to decompress in place. The end mark is about 8.25 bytes long,
  51. * and the worst case symbol is about 16.5 bytes long. Therefore
  52. * We need to reserve at least 25 bytes of slack here.
  53. * Currently I reserve 2048 bytes of just slack to be safe :)
  54. * 2048 bytes easily falls within the BSS (the defualt stack is 4096 bytes)
  55. * so we really are decompressing in place.
  56. *
  57. * Hmm. I missed a trick. In the very worst case (no compression)
  58. * the encoded data is 9/8 the size as it started out so to be completely
  59. * safe I need to be 1/8 of the uncompressed code size past the end.
  60. * This will still fit compfortably into our bss in any conceivable scenario.
  61. */
  62. _compressed_copy = _edata + _prefix_size - _compressed_size +
  63. /* The amount to overflow _edata */
  64. MAX( ((_edata - _text + 7) / 8) , 2016 ) + 32;
  65. _assert = ASSERT( ( _compressed_copy - _prefix_size ) < _ebss , "Cannot decompress in place" ) ;
  66. decompress = DEFINED(decompress) ? decompress : 0;
  67. /DISCARD/ : {
  68. *(.comment)
  69. *(.note)
  70. }
  71. /* Symbols used by the prefixes whose addresses are inconvinient
  72. * to compute, at runtime in the code.
  73. */
  74. image_basemem_size = DEFINED(image_basemem_size)? image_basemem_size : 65536;
  75. image_basemem = DEFINED(image_basemem)? image_basemem : 65536;
  76. _prefix_real_to_prot = _real_to_prot + _prefix_size ;
  77. _prefix_prot_to_real = _prot_to_real + _prefix_size ;
  78. _prefix_image_basemem_size = image_basemem_size + _prefix_size ;
  79. _prefix_image_basemem = image_basemem + _prefix_size ;
  80. _prefix_rm_in_call = _rm_in_call + _prefix_size ;
  81. _prefix_in_call = _in_call + _prefix_size ;
  82. _prefix_rom = rom + _prefix_size ;
  83. _prefix_rm_etherboot_location = rm_etherboot_location + _prefix_size ;
  84. _prefix_stack_end = _stack_end + _prefix_size ;
  85. }