2

我编译了一个简单的目标文件文件并尝试与 链接ld,但它给出了警告。但是,文件有_start符号,这是readelf对象的。

ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              REL (Relocatable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x40
  Start of program headers:          0 (bytes into file)
  Start of section headers:          59392 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         0
  Size of section headers:           64 (bytes)
  Number of section headers:         6
  Section header string table index: 5
(...)
Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .text             PROGBITS         0000000000000000  00000040
       000000000000005c  0000000000000000  AX       0     0     1
  [ 2] .data             PROGBITS         0000000000000000  00001040
       0000000000001000  0000000000000000  WA       0     0     8
  [ 3] .symtab           SYMTAB           0000000000000000  00003400
       0000000000000030  0000000000000018           4     2     8
  [ 4] .strtab           STRTAB           0000000000000000  00003800
       0000000000000400  0000000000000000           0     0     1
  [ 5] .shstrtab         STRTAB           0000000000000000  00003000
       0000000000000400  0000000000000000           0     0     1
(...)
Symbol table '.symtab' contains 2 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 0000000000000000    87 FUNC    GLOBAL DEFAULT    1 _start

这里可能是什么问题

4

1 回答 1

1

所以,我发现了问题。info符号节头必须是_start函数在符号表中的索引。但由于某种原因,链接器后来改变了,但它工作得很好!

于 2020-04-15T22:57:17.707 回答