“ ld:警告:找不到条目符号_start;默认为0000000000401000”,带有自定义* .o文件

问题描述 投票:2回答:1

我已经编译了一个简单的目标文件文件,并尝试与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

这里可能是什么问题

c++ elf entry-point readelf
1个回答
1
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.