评论部分的非零地址值有什么用?

如何解决评论部分的非零地址值有什么用?

我们正在努力复制与参考相同的.elf文件。我们几乎在那儿,文件是相同的,但是注释部分的地址相同(其余都是二进制方式100%相同)。

使用readelf -e转储一个.elf文件的方法如下(目标是powerpc,但我认为这并不重要):

ELF Header:
  Magic:   7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement,big endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           PowerPC
  Version:                           0x1
  Entry point address:               0x1800f88
  Start of program headers:          52 (bytes into file)
  Start of section headers:          1367724 (bytes into file)
  Flags:                             0x0
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         5
  Size of section headers:           40 (bytes)
  Number of section headers:         20
  Section header string table index: 19

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .interp           PROGBITS        018000f4 0000f4 000011 00   A  0   0  1
  [ 2] .hash             HASH            01800108 000108 000248 04   A  3   0  4
  [ 3] .dynsym           DYNSYM          01800350 000350 0004d0 10   A  4   1  4
  [ 4] .dynstr           STRTAB          01800820 000820 000473 00   A  0   0  1
  [ 5] .rela.plt         RELA            01800c94 000c94 0002dc 0c   A  3  16  4
  [ 6] .rela.sbss        RELA            01800f70 000f70 000018 0c   A  3  15  4
  [ 7] .text             PROGBITS        01800f88 000f88 0e4f78 00  AX  0   0  4
  [ 8] .rodata           PROGBITS        018e5f00 0e5f00 064708 00   A  0   0  8
  [ 9] .sdata2           PROGBITS        0194a608 14a608 000000 00   A  0   0  4
  [10] .data             PROGBITS        0198a608 14a608 000b5c 00  WA  0   0  8
  [11] .dynamic          DYNAMIC         0198b164 14b164 000090 08  WA  4   0  4
  [12] .got2             PROGBITS        0198b1f4 14b1f4 000024 00  WA  0   0  1
  [13] .got              PROGBITS        0198b218 14b218 000010 04  WA  0   0  4
  [14] .sdata            PROGBITS        0198b228 14b228 001814 00  WA  0   0  8
  [15] .sbss             NOBITS          0198ca40 14ca40 00064c 00  WA  0   0  8
  [16] .plt              NOBITS          0198d08c 14ca40 000324 00 WAX  0   0  4
  [17] .bss              NOBITS          0198d3b0 14ca40 223920 00  WA  0   0 16
  [18] .comment          PROGBITS        0026a8bd 14ca40 0013cb 00      0   0  1
  [19] .shstrtab         STRTAB          00000000 14de0b 00009e 00      0   0  1

地址为0的部分是有意义的:在加载程序时,这些部分未映射。其他0x18xxxxx值由链接器规范文件指定。

但是为什么注释部分有一个非零的地址(其中包含诸如编译器版本和执行平台之类的详细信息),链中的哪一部分使用了它(调试器?),以及链接程序如何确定放置在何处它吗?

链接描述文件甚至没有提到.comment部分:

OUTPUT_FORMAT("elf32-powerpc","elf32-powerpc","elf32-powerpc")
OUTPUT_ARCH(powerpc)
ENTRY(_start)
SEARCH_DIR(/opt/gnu/powerpc-wrs-vxworks/lib);
/* Do we need any of these for elf?
__DYNAMIC = 0;    */
PROVIDE (__stack = 0);
SECTIONS
{
/* Read-only sections,merged into text segment: */
. = 0x01800000 + SIZEOF_HEADERS;
.interp   : { *(.interp) }
.hash         : { *(.hash)      }
.dynsym   : { *(.dynsym)        }
.dynstr   : { *(.dynstr)        }
.gnu.version   : { *(.gnu.version)      }
.gnu.version_d   : { *(.gnu.version_d)  }
.gnu.version_r   : { *(.gnu.version_r)  }
.rela.text     :
{ *(.rela.text) *(.rela.gnu.linkonce.t*) }
.rela.data     :
{ *(.rela.data) *(.rela.gnu.linkonce.d*) }
.rela.rodata   :
{ *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
.rela.got     : { *(.rela.got)  }
.rela.got1    : { *(.rela.got1) }
.rela.got2    : { *(.rela.got2) }
.rela.ctors   : { *(.rela.ctors)    }
.rela.dtors   : { *(.rela.dtors)    }
.rela.init    : { *(.rela.init) }
.rela.fini    : { *(.rela.fini) }
.rela.bss     : { *(.rela.bss)  }
.rela.plt     : { *(.rela.plt)  }
.rela.sdata   : { *(.rela.sdata)    }
.rela.sbss    : { *(.rela.sbss) }
.rela.sdata2      : { *(.rela.sdata2)   }
.rela.sbss2   : { *(.rela.sbss2)    }
.text      :
{
*(.text)
/* .gnu.warning sections are handled specially by elf32.em.  */
*(.gnu.warning)
*(.gnu.linkonce.t*)
} =0
.init         : { *(.init)      } =0
.fini         : { *(.fini)      } =0
.rodata   : { *(.rodata) *(.gnu.linkonce.r*) }
.rodata1      : { *(.rodata1) }
_etext = .;
PROVIDE (etext = .);
.sdata2   : { *(.sdata2) }
.sbss2   : { *(.sbss2) }
/* Adjust the address for the data segment.  We want to adjust up to
the same address within the page on the next page up.  It would
be more correct to do this:
. = ALIGN(0x40000) + (ALIGN(8) & (0x40000 - 1));
The current expression does not correctly handle the case of a
text segment ending precisely at the end of a page; it causes the
data segment to skip a page.  The above expression does not have
this problem,but it will currently (2/95) cause BFD to allocate
a single segment,combining both text and data,for this case.
This will prevent the text segment from being shared among
multiple executions of the program; I think that is more
important than losing a page of the virtual address space (note
that no actual memory is lost; the page which is skipped can not
be referenced).  */
. =  ALIGN(8) + 0x40000;
.data    :
{
*(.data)
*(.gnu.linkonce.d*)
CONSTRUCTORS
}
.data1   : { *(.data1) }
.got1         : { *(.got1) }
.dynamic      : { *(.dynamic) }
/* Put .ctors and .dtors next to the .got2 section,so that the pointers
get relocated with -mrelocatable. Also put in the .fixup pointers.
The current compiler no longer needs this,but keep it around for 2.7.2  */
PROVIDE (_GOT2_START_ = .);
.got2         :  { *(.got2) }
PROVIDE (__CTOR_LIST__ = .);
.ctors    : { *(.ctors) }
PROVIDE (__CTOR_END__ = .);
PROVIDE (__DTOR_LIST__ = .);
.dtors    : { *(.dtors) }
PROVIDE (__DTOR_END__ = .);
PROVIDE (_FIXUP_START_ = .);
.fixup    : { *(.fixup) }
PROVIDE (_FIXUP_END_ = .);
PROVIDE (_GOT2_END_ = .);
PROVIDE (_GOT_START_ = .);
.got          : { *(.got) }
.got.plt      : { *(.got.plt) }
PROVIDE (_GOT_END_ = .);
/* We want the small data sections together,so single-instruction offsets
can access them all,and initialized data all before uninitialized,so
we can shorten the on-disk segment size.  */
.sdata    : { *(.sdata) }
_edata  =  .;
PROVIDE (edata = .);
.sbss      :
{
PROVIDE (__sbss_start = .);
*(.sbss)
*(.scommon)
*(.dynsbss)
PROVIDE (__sbss_end = .);
}
.plt   : { *(.plt) }
.bss       :
{
PROVIDE (__bss_start = .);
*(.dynbss)
*(.bss)
*(COMMON)
}
_end = . ;
PROVIDE (end = .);
/* These are needed for ELF backends which have not yet been
converted to the new style linker.  */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0.  */
/* DWARF 1 */
.debug          0 : { *(.debug) }
.line           0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo  0 : { *(.debug_srcinfo) }
.debug_sfnames  0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges  0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info     0 : { *(.debug_info) }
.debug_abbrev   0 : { *(.debug_abbrev) }
.debug_line     0 : { *(.debug_line) }
.debug_frame    0 : { *(.debug_frame) }
.debug_str      0 : { *(.debug_str) }
.debug_loc      0 : { *(.debug_loc) }
.debug_macinfo  0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames  0 : { *(.debug_varnames) }
/* These must appear regardless of  .  */
}

链接器版本也很旧(是的,我知道...):

GNU ld 2.9.1
Copyright 1997 Free Software Foundation,Inc.

解决方法

但是为什么评论部分的地址不为零

链接器中很可能存在一个错误,该错误将未初始化的数据存储在其中(数据无关紧要,但是可复制的构建的设计目标,因此无法实现可复制的构建一个错误)。

您没有说您使用了哪个链接器(和哪个版本)。

使用GNU ld (GNU Binutils for Debian) 2.34GNU gold (GNU Binutils for Debian 2.34) 1.16,对于00000000部分的.comment,我始终得到Addr

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 <select id="xxx"> SELECT di.id, di.name, di.work_type, di.updated... <where> <if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 <property name="dynamic.classpath" value="tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams['font.sans-serif'] = ['SimHei'] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -> systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping("/hires") public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate<String
使用vite构建项目报错 C:\Users\ychen\work>npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-