Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 9.28 KB | None | 0 0
  1. /*
  2.  * Linkscript for Wii
  3.  */
  4.  
  5. OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc");
  6. OUTPUT_ARCH(powerpc:common);
  7. EXTERN(_start);
  8. ENTRY(_start);
  9.  
  10. PHDRS
  11. {
  12.   stub PT_LOAD FLAGS(5);
  13.   text PT_LOAD FLAGS(5);
  14.   data PT_LOAD FLAGS(6);
  15.   bss  PT_NULL;
  16. }
  17.  
  18. SECTIONS
  19. {
  20.     /* stub is loaded at physical address 0x00003400 (though both 0x80003400 and 0x00003400 are equivalent for IOS) */
  21.     /* This can also be used to load an arbitrary standalone stub at an arbitrary address in memory, for any purpose */
  22.     /* Use -Wl,--section-start,.stub=0xADDRESS to change */
  23.     . = 0x00003400;
  24.  
  25.     .stub :
  26.     {
  27.         KEEP(*(.stub))
  28.     } :stub = 0
  29.  
  30.     /* default base address */
  31.     /* use -Wl,--section-start,.init=0xADDRESS to change */
  32.     . = 0x80004000;
  33.  
  34.     /* Program */
  35.     .init          :
  36.     {
  37.         KEEP (*crt0.o(*.init))
  38.         KEEP (*(.init))
  39.     } :text = 0
  40.     .plt      : { *(.plt)   }
  41.     .interp         : { *(.interp)  }
  42.     .hash           : { *(.hash) }
  43.     .dynsym         : { *(.dynsym) }
  44.     .dynstr         : { *(.dynstr) }
  45.     .gnu.version    : { *(.gnu.version) }
  46.     .gnu.version_d  : { *(.gnu.version_d) }
  47.     .gnu.version_r  : { *(.gnu.version_r) }
  48.     .rel.init       : { *(.rel.init) }
  49.     .rela.init      : { *(.rela.init) }
  50.     .rel.text       : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
  51.     .rela.text      : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
  52.     .rel.fini       : { *(.rel.fini) }
  53.     .rela.fini      : { *(.rela.fini) }
  54.     .rel.rodata     : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
  55.     .rela.rodata    : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
  56.     .rel.data       : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
  57.     .rela.data      : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
  58.     .rel.tdata      : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
  59.     .rela.tdata     : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
  60.     .rel.tbss       : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
  61.     .rela.tbss      : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
  62.     .rel.ctors      : { *(.rel.ctors) }
  63.     .rela.ctors     : { *(.rela.ctors) }
  64.     .rel.dtors      : { *(.rel.dtors) }
  65.     .rela.dtors     : { *(.rela.dtors) }
  66.     .rel.got        : { *(.rel.got) }
  67.     .rela.got       : { *(.rela.got) }
  68.     .rela.got1      : { *(.rela.got1) }
  69.     .rela.got2      : { *(.rela.got2) }
  70.     .rel.sdata      : { *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) }
  71.     .rela.sdata     : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) }
  72.     .rel.sbss       : { *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) }
  73.     .rela.sbss      : { *(.rela.sbss .rela.sbss.* .rel.gnu.linkonce.sb.*) }
  74.     .rel.sdata2     : { *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) }
  75.     .rela.sdata2    : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) }
  76.     .rel.sbss2      : { *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) }
  77.     .rela.sbss2     : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) }
  78.     .rel.bss        : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
  79.     .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
  80.     .rel.plt        : { *(.rel.plt) }
  81.     .rela.plt       : { *(.rela.plt) }
  82.  
  83.     .text      :
  84.     {
  85.         *(.text)
  86.         *(.text.*)
  87.         /* .gnu.warning sections are handled specially by elf32.em.  */
  88.         *(.gnu.warning)
  89.         *(.gnu.linkonce.t.*)
  90.         . = ALIGN(32);   /* REQUIRED. LD is flaky without it. */
  91.     } = 0
  92.  
  93.     .fini      :
  94.     {
  95.         KEEP (*(.fini))
  96.         . = ALIGN(32);   /* REQUIRED. LD is flaky without it. */
  97.     } = 0
  98.    
  99.     PROVIDE (__etext = .);
  100.     PROVIDE (_etext = .);
  101.     PROVIDE (etext = .);
  102.  
  103.     .rodata   : { *(.rodata) *(.rodata.*) *(.gnu.linkonce.r.*) } :data
  104.     .rodata1   : { *(.rodata1) }
  105.     .sdata2   : { *(.sdata2) *(.sdata2.*) *(.gnu.linkonce.s2.*) }
  106.     .sbss2   : { *(.sbss2) *(.sbss2.*) *(.gnu.linkonce.sb2.*) }
  107.   /* Adjust the address for the data segment.  We want to adjust up to
  108.      the same address within the page on the next page up.  */
  109.   /* Ensure the __preinit_array_start label is properly aligned.  We
  110.      could instead move the label definition inside the section, but
  111.      the linker would then create the section even if it turns out to
  112.      be empty, which isn't pretty.  */
  113.     . = ALIGN(32 / 8);
  114.     PROVIDE (__preinit_array_start = .);
  115.     .preinit_array     : { *(.preinit_array) }
  116.     PROVIDE (__preinit_array_end = .);
  117.     PROVIDE (__init_array_start = .);
  118.     .init_array     : { *(.init_array) }
  119.     PROVIDE (__init_array_end = .);
  120.     PROVIDE (__fini_array_start = .);
  121.     .fini_array     : { *(.fini_array) }
  122.     PROVIDE (__fini_array_end = .);
  123.     .data    :
  124.     {
  125.         *(.data)
  126.         *(.data.*)
  127.         *(.gnu.linkonce.d.*)
  128.         SORT(CONSTRUCTORS)
  129.         . = ALIGN(32);   /* REQUIRED. LD is flaky without it. */
  130.     }
  131.  
  132.     .data1   : { *(.data1) }
  133.     .tdata    : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
  134.     .tbss         : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
  135.     .eh_frame : { KEEP (*(.eh_frame)) }
  136.     .gcc_except_table : { *(.gcc_except_table) }
  137.     .fixup          : { *(.fixup) }
  138.     .got1           : { *(.got1) }
  139.     .got2           : { *(.got2) }
  140.     .dynamic       : { *(.dynamic) }
  141.  
  142.     .ctors   :
  143.     {
  144.     /*  gcc uses crtbegin.o to find the start of
  145.         the constructors, so we make sure it is
  146.         first.  Because this is a wildcard, it
  147.         doesn't matter if the user does not
  148.         actually link against crtbegin.o; the
  149.         linker won't look for a file to match a
  150.         wildcard.  The wildcard also means that it
  151.         doesn't matter which directory crtbegin.o
  152.         is in.  */
  153.  
  154.         KEEP (*crtbegin.o(.ctors))
  155.  
  156.     /*  We don't want to include the .ctor section from
  157.         from the crtend.o file until after the sorted ctors.
  158.         The .ctor section from the crtend file contains the
  159.         end of ctors marker and it must be last */
  160.  
  161.         KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
  162.         KEEP (*(SORT(.ctors.*)))
  163.         KEEP (*(.ctors))
  164.         . = ALIGN(32);   /* REQUIRED. LD is flaky without it. */
  165.     }
  166.  
  167.     .dtors         :
  168.     {
  169.         KEEP (*crtbegin.o(.dtors))
  170.         KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors))
  171.         KEEP (*(SORT(.dtors.*)))
  172.         KEEP (*(.dtors))
  173.         . = ALIGN(32);   /* REQUIRED. LD is flaky without it. */
  174.     }
  175.  
  176.     .jcr            : { KEEP (*(.jcr)) }
  177.     .got          : { *(.got.plt) *(.got) }
  178.  
  179.  
  180.     /*  We want the small data sections together, so single-instruction offsets
  181.         can access them all, and initialized data all before uninitialized, so
  182.         we can shorten the on-disk segment size.  */
  183.  
  184.     .sdata     :
  185.     {
  186.         *(.sdata)
  187.         *(.sdata.*)
  188.         *(.gnu.linkonce.s.*)
  189.         . = ALIGN(32);   /* REQUIRED. LD is flaky without it. */
  190.     }
  191.  
  192.     _edata = .;
  193.     PROVIDE (edata = .);
  194.    
  195.     .sbss      :
  196.     {
  197.         __sbss_start = .;
  198.         PROVIDE (__sbss_start = .);
  199.         PROVIDE (___sbss_start = .);
  200.         *(.dynsbss)
  201.         *(.sbss)
  202.         *(.sbss.*)
  203.         *(.gnu.linkonce.sb.*)
  204.         *(.scommon)
  205.         PROVIDE (__sbss_end = .);
  206.         PROVIDE (___sbss_end = .);
  207.         . = ALIGN(32);   /* REQUIRED. LD is flaky without it. */
  208.         __sbss_end = .;
  209.     }
  210.  
  211.     _end = .;
  212.     PROVIDE(end = .);
  213.  
  214.     /*. = 0x90002000;*/  
  215.   . = (0x933E0000 - 0x800000);
  216.  
  217.     .bss       :
  218.     {
  219.         __bss_start = .;
  220.         PROVIDE (__bss_start = .);
  221.         *(.dynbss)
  222.         *(.bss)
  223.         *(.bss.*)
  224.         *(.gnu.linkonce.b.*)
  225.         *(COMMON)
  226.     /*  Align here to ensure that the .bss section occupies space up to
  227.         _end.  Align after .bss to ensure correct alignment even if the
  228.         .bss section disappears because there are no input sections.  */
  229.  
  230.         . = ALIGN(32);
  231.  
  232.         PROVIDE (__bss_end = .);
  233.         __bss_end = .;
  234.     }
  235.  
  236.     /* Stabs debugging sections.  */
  237.     .stab 0 : { *(.stab) }
  238.     .stabstr 0 : { *(.stabstr) }
  239.     .stab.excl 0 : { *(.stab.excl) }
  240.     .stab.exclstr 0 : { *(.stab.exclstr) }
  241.     .stab.index 0 : { *(.stab.index) }
  242.     .stab.indexstr 0 : { *(.stab.indexstr) }
  243.     .comment 0 : { *(.comment) }
  244.     /*  DWARF debug sections.
  245.         Symbols in the DWARF debugging sections are relative to the beginning
  246.         of the section so we begin them at 0.  */
  247.     /* DWARF 1 */
  248.     .debug          0 : { *(.debug) }
  249.     .line           0 : { *(.line) }
  250.     /* GNU DWARF 1 extensions */
  251.     .debug_srcinfo  0 : { *(.debug_srcinfo) }
  252.     .debug_sfnames  0 : { *(.debug_sfnames) }
  253.     /* DWARF 1.1 and DWARF 2 */
  254.     .debug_aranges  0 : { *(.debug_aranges) }
  255.     .debug_pubnames 0 : { *(.debug_pubnames) }
  256.     /* DWARF 2 */
  257.     .debug_info     0 : { *(.debug_info) }
  258.     .debug_abbrev   0 : { *(.debug_abbrev) }
  259.     .debug_line     0 : { *(.debug_line) }
  260.     .debug_frame    0 : { *(.debug_frame) }
  261.     .debug_str      0 : { *(.debug_str) }
  262.     .debug_loc      0 : { *(.debug_loc) }
  263.     .debug_macinfo  0 : { *(.debug_macinfo) }
  264.     /* SGI/MIPS DWARF 2 extensions */
  265.     .debug_weaknames 0 : { *(.debug_weaknames) }
  266.     .debug_funcnames 0 : { *(.debug_funcnames) }
  267.     .debug_typenames 0 : { *(.debug_typenames) }
  268.     .debug_varnames  0 : { *(.debug_varnames) }
  269.     /* These must appear regardless of  .  */
  270. }
  271.  
  272. __isIPL = 0;
  273. __stack_addr = (__sbss_start + SIZEOF(.sbss) + 0x20000 + 7) & (-8);
  274. __stack_end = (__sbss_start + SIZEOF(.sbss));
  275. __intrstack_addr = (__stack_addr + 0x4000);
  276. __intrstack_end = (__stack_addr);
  277. __Arena1Lo =( __intrstack_end + 31) & (-32);
  278. __Arena1Hi = (0x817FEFF0);
  279. __Arena2Lo = (0x90002000);
  280. __Arena2Hi = (__bss_start - 33) & (-32);
  281.  
  282. __gxregs = (__Arena1Hi + 31) & (-32);
  283. __ipcbufferLo = __Arena2Hi;
  284. __ipcbufferHi = (0x93400000);
  285.  
  286. /* for backward compatibility with old crt0 */
  287. PROVIDE (__stack = (0x817FEFF0));
  288.  
  289. PROVIDE(__isIPL = __isIPL);
  290. PROVIDE(__stack_addr = __stack_addr);
  291. PROVIDE(__stack_end = __stack_end);
  292. PROVIDE(__intrstack_addr = __intrstack_addr);
  293. PROVIDE(__intrstack_end = __intrstack_end);
  294. PROVIDE(__Arena1Lo = __Arena1Lo);
  295. PROVIDE(__Arena1Hi = __Arena1Hi);
  296. PROVIDE(__Arena2Lo = __Arena2Lo);
  297. PROVIDE(__Arena2Hi = __Arena2Hi);
  298. PROVIDE(__ipcbufferLo = __ipcbufferLo);
  299. PROVIDE(__ipcbufferHi = __ipcbufferHi);
  300. PROVIDE(__gxregs = __gxregs);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement