舌头两边起泡是艾滋病:【转】 揪出gcc默认使用的ld链接脚本

来源:百度文库 编辑:九乡新闻网 时间:2024/05/02 03:01:04

揪出gcc默认使用的ld链接脚本

 首先声明不是讲lds语法的

  在  <<程序员的自我修养-链接装载与库>>一书中曾提到ld默认使用的链接脚本

  说默认在/usr/lib/ldscripts/下

  结果我找了半天没找到  我的系统是fedora 8

  find / -name *lds*  找不到 找script也找不到 晕了

  后来查了下发现可以用ld -verbose查看默认的lds

  输出如下:

  GNU ld version 2.19.51.0.14-34.fc12 20090722

  Supported emulations:

  elf_i386

  i386linux

  elf_x86_64

  using internal linker script:

  ==================================================

  /* Script for -z combreloc: combine and sort reloc sections */

  OUTPUT_FORMAT("elf32-i386", "elf32-i386",

  "elf32-i386")

  OUTPUT_ARCH(i386)

  ENTRY(_start)

  SEARCH_DIR("/usr/i686-redhat-linux/lib"); SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib");

  SECTIONS

  {

  /* Read-only sections, merged into text segment: */

  PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x08048000)); . = SEGMENT_START("text-segment",

  0x08048000) + SIZEOF_HEADERS;

  ........

  后面略

  这就奇怪了,那么这个lds到底在哪呢?

  我们用find /usr/* |xargs grep "Script for -z combreloc"看看

  结果 Binary file /usr/bin/ld matches 可见已经集成到ld中了

  readelf -P --string-dump=.rodata ld便可以找到