[PATCH] D27516: [ELF] - Place ".text" to be first section if -Ttext is used.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 7 10:35:50 PST 2016


grimar added a comment.

In https://reviews.llvm.org/D27516#616079, @ruiu wrote:

> Isn't this an ad-hoc fix for that specific case? The real problem is that, if it --section-start (or equivalently -T{bss,data,text}) are used, we need to map them without overlapping to other sections.


gold seems does only cares about -Ttext. For example if -Ttext=0x100 -Tdata=0x20000 -Tbss=0x30000 is given, gold output for that is:

  Section Headers:
    [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
    [ 0]                   NULL            00000000 000000 000000 00      0   0  0
    [ 1] .text             PROGBITS        00000100 0000a0 00ba74 00  AX  0   0 16
    [ 2] .rodata           PROGBITS        0000bb80 00bb20 0035fc 00   A  0   0 16
    [ 3] .got              PROGBITS        0000f17c 00f11c 000000 00  WA  0   0  4
    [ 4] .got.plt          PROGBITS        0000f17c 00f11c 00000c 00  WA  0   0  4
    [ 5] .data             PROGBITS        0000f188 00f128 000130 00  WA  0   0  4
    [ 6] COMMON            NOBITS          0000f2b8 00f260 000044 00  WA  0   0 16
    [ 7] .bss              NOBITS          0000f300 00f2a8 0093a0 00  WA  0   0  8

bfd in opposite tries to layout everything:

  Section Headers:
    [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
    [ 0]                   NULL            00000000 000000 000000 00      0   0  0
    [ 1] .text             PROGBITS        00000100 0000c0 00ba74 00 WAX  0   0 16
    [ 2] .data             PROGBITS        00020000 00f140 000130 00  WA  0   0  4
    [ 3] .bss              NOBITS          00030000 00f270 0093e8 00  WA  0   0 16
    [ 4] .rodata           PROGBITS        0000bb80 00bb40 0035f4 00   A  0   0 16
    [ 5] .got.plt          PROGBITS        0000f174 00f134 00000c 04  WA  0   0  4


https://reviews.llvm.org/D27516





More information about the llvm-commits mailing list