[PATCH] D52830: [ELF] - Set sh_info and sh_link for .rela.plt sections.

Ed Maste via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 9 08:55:08 PDT 2018


emaste added a comment.

I backported the change to lld 6.0 currently in FreeBSD-HEAD and it has the expected behaviour, but for my test case I think `sh_info` should reference `.got.plt` not `.plt` - note the address marked with `########` below.

That said, in practice it will address the issue we have with ELF Tool Chain's strip either way (the important part is that `sh_info` references a section that isn't being removed.

  There are 36 section headers, starting at offset 0x434420:
  
  Section Headers:
    [Nr] Name              Type            Addr             Off    Size   ES Flg Lk Inf Al
    [ 0]                   NULL            0000000000000000 000000 000000 00      0   0  0
    [ 1] .note.tag         NOTE            0000000000200238 000238 000030 00   A  0   0  4
    [ 2] .rodata           PROGBITS        0000000000200280 000280 017f20 00 AMS  0   0 64
    [ 3] .rela.plt         RELA            00000000002181a0 0181a0 000018 18   A 33   9  8
                                                                                     **
    [ 4] .eh_frame_hdr     PROGBITS        00000000002181b8 0181b8 003b54 00   A  0   0  1
    [ 5] .eh_frame         PROGBITS        000000000021bd10 01bd10 0100a0 00   A  0   0  8
    [ 6] .text             PROGBITS        000000000022c000 02c000 0bdbf8 00  AX  0   0 16
    [ 7] .init             PROGBITS        00000000002e9bf8 0e9bf8 000013 00  AX  0   0  4
    [ 8] .fini             PROGBITS        00000000002e9c0c 0e9c0c 00000e 00  AX  0   0  4
    [ 9] .plt              PROGBITS        00000000002e9c20 0e9c20 000010 00  AX  0   0 16
     **
    [10] .data             PROGBITS        00000000002ea000 0ea000 003aa0 00  WA  0   0 16
    [11] .got.plt          PROGBITS        00000000002edaa0 0edaa0 000008 00  WA  0   0  8
  ...                                      ################
    [33] .symtab           SYMTAB          0000000000000000 4148f8 012d38 18     35 1582  8
    [34] .shstrtab         STRTAB          0000000000000000 427630 00016f 00      0   0  1
    [35] .strtab           STRTAB          0000000000000000 42779f 00cc7b 00      0   0  1
  Key to Flags:
    W (write), A (alloc), X (execute), M (merge), S (strings)
    I (info), L (link order), G (group), x (unknown)
    O (extra OS processing required) o (OS specific), p (processor specific)
  
  nuc% readelf -r make.full
  
  Relocation section with addend (.rela.plt):
  r_offset     r_info       r_type              st_value         st_name + r_addend
  0000002edaa0 000000000025 R_X86_64_IRELATIVE  0000000000000000  + 2e91f0
  ############
  nuc% 


https://reviews.llvm.org/D52830





More information about the llvm-commits mailing list