[llvm-bugs] [Bug 35474] New: --emit-relocs produces wrongly-named reloc sections

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Nov 29 19:13:13 PST 2017


https://bugs.llvm.org/show_bug.cgi?id=35474

            Bug ID: 35474
           Summary: --emit-relocs produces wrongly-named reloc sections
           Product: lld
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: roland at hack.frob.com
                CC: jakehehrlich at google.com, llvm-bugs at lists.llvm.org,
                    phosek at chromium.org

The reloc sections emitted by --emit-relocs should have names that are
'.rela' (or '.rel') prepended to the corresponding output section name.
GNU linkers do this.  LLD names multiple reloc sections for some section (I
don't know how it chooses), so there wind up being multiple reloc sections
by the same name though they correctly point (sh_info) to differently-named
sections.

        $ cat foo.ld
        SECTIONS {
          . = 0x100000;
          .text.boot : { *(.text.boot) }
          .text : { *(.text) }
        }
        $ cat foo.s
        .section .text.boot,"ax"
        foo: mov $bar, %rax

        .section .text,"ax"
        bar: mov $foo, %rax
        $ gcc -c foo.s
        $ readelf -WS foo.o
        There are 10 section headers, starting at offset 0x180:

        Section Headers:
          [Nr] Name              Type            Address          Off    Size  
ES Flg Lk Inf Al
          [ 0]                   NULL            0000000000000000 000000 000000
00      0   0  0
          [ 1] .text             PROGBITS        0000000000000000 000040 000007
00  AX  0   0  1
          [ 2] .rela.text        RELA            0000000000000000 000108 000018
18   I  7   1  8
          [ 3] .data             PROGBITS        0000000000000000 000047 000000
00  WA  0   0  1
          [ 4] .bss              NOBITS          0000000000000000 000047 000000
00  WA  0   0  1
          [ 5] .text.boot        PROGBITS        0000000000000000 000047 000007
00  AX  0   0  1
          [ 6] .rela.text.boot   RELA            0000000000000000 000120 000018
18   I  7   5  8
          [ 7] .symtab           SYMTAB          0000000000000000 000050 0000a8
18      8   7  8
          [ 8] .strtab           STRTAB          0000000000000000 0000f8 000009
00      0   0  1
          [ 9] .shstrtab         STRTAB          0000000000000000 000138 000041
00      0   0  1
        Key to Flags:
          W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
          L (link order), O (extra OS processing required), G (group), T (TLS),
          C (compressed), x (unknown), o (OS specific), E (exclude),
          l (large), p (processor specific)
        $ ld.lld --emit-relocs -o foo.lld -T foo.ld foo.o
        ld.lld: warning: cannot find entry symbol _start; defaulting to
0x100007
        $ readelf -WS foo.lld
        There are 11 section headers, starting at offset 0x1180:

        Section Headers:
          [Nr] Name              Type            Address          Off    Size  
ES Flg Lk Inf Al
          [ 0]                   NULL            0000000000000000 000000 000000
00      0   0  0
          [ 1] .text.boot        PROGBITS        0000000000100000 001000 000007
00  AX  0   0  1
          [ 2] .text             PROGBITS        0000000000100007 001007 000007
00  AX  0   0  1
          [ 3] .data             PROGBITS        000000000010000e 00100e 000000
00  WA  0   0  1
          [ 4] .bss              NOBITS          000000000010000e 00100e 000000
00  WA  0   0  1
          [ 5] .rela.text        RELA            0000000000000000 001010 000018
18   I  8   2  8
          [ 6] .rela.text        RELA            0000000000000000 001028 000018
18   I  8   1  8
          [ 7] .comment          PROGBITS        0000000000000000 001040 000021
01  MS  0   0  1
          [ 8] .symtab           SYMTAB          0000000000000000 001068 0000c0
18     10   8  8
          [ 9] .shstrtab         STRTAB          0000000000000000 001128 00004b
00      0   0  1
          [10] .strtab           STRTAB          0000000000000000 001173 000009
00      0   0  1
        Key to Flags:
          W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
          L (link order), O (extra OS processing required), G (group), T (TLS),
          C (compressed), x (unknown), o (OS specific), E (exclude),
          l (large), p (processor specific)
        $ ld.bfd --emit-relocs -o foo.bfd -T foo.ld foo.o
        $ readelf -WS foo.bfd
        There are 10 section headers, starting at offset 0x1001a0:

        Section Headers:
          [Nr] Name              Type            Address          Off    Size  
ES Flg Lk Inf Al
          [ 0]                   NULL            0000000000000000 000000 000000
00      0   0  0
          [ 1] .text.boot        PROGBITS        0000000000100000 100000 000007
00  AX  0   0  1
          [ 2] .rela.text.boot   RELA            0000000000000000 100128 000018
18   I  7   1  8
          [ 3] .text             PROGBITS        0000000000100007 100007 000007
00  AX  0   0  1
          [ 4] .rela.text        RELA            0000000000000000 100140 000018
18   I  7   3  8
          [ 5] .data             PROGBITS        000000000010000e 10000e 000000
00  WA  0   0  1
          [ 6] .bss              NOBITS          000000000010000e 10000e 000000
00  WA  0   0  1
          [ 7] .symtab           SYMTAB          0000000000000000 100010 0000f0
18      8  10  8
          [ 8] .strtab           STRTAB          0000000000000000 100100 000025
00      0   0  1
          [ 9] .shstrtab         STRTAB          0000000000000000 100158 000041
00      0   0  1
        Key to Flags:
          W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
          L (link order), O (extra OS processing required), G (group), T (TLS),
          C (compressed), x (unknown), o (OS specific), E (exclude),
          l (large), p (processor specific)
        $ ld.gold --emit-relocs -o foo.gold -T foo.ld foo.o
        $ readelf -WS foo.gold
        There are 11 section headers, starting at offset 0x1190:

        Section Headers:
          [Nr] Name              Type            Address          Off    Size  
ES Flg Lk Inf Al
          [ 0]                   NULL            0000000000000000 000000 000000
00      0   0  0
          [ 1] .text.boot        PROGBITS        0000000000100000 001000 000007
00  AX  0   0  1
          [ 2] .text             PROGBITS        0000000000100054 001054 000007
00  AX  0   0  1
          [ 3] .data             PROGBITS        000000000010005b 00105b 000000
00  WA  0   0  1
          [ 4] .bss              NOBITS          000000000010005b 00105b 000000
00  WA  0   0  1
          [ 5] .rela.text        RELA            0000000000000000 001060 000018
18   I  8   2  8
          [ 6] .rela.text.boot   RELA            0000000000000000 001078 000018
18   I  8   1  8
          [ 7] .note.gnu.gold-version NOTE            0000000000000000 001090
00001c 00      0   0  4
          [ 8] .symtab           SYMTAB          0000000000000000 0010b0 000078
18      9   5  8
          [ 9] .strtab           STRTAB          0000000000000000 001128 000009
00      0   0  1
          [10] .shstrtab         STRTAB          0000000000000000 001131 000058
00      0   0  1
        Key to Flags:
          W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
          L (link order), O (extra OS processing required), G (group), T (TLS),
          C (compressed), x (unknown), o (OS specific), E (exclude),
          l (large), p (processor specific)
        $

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171130/2b33d1fa/attachment-0001.html>


More information about the llvm-bugs mailing list