在 <<程序員的自我修養(yǎng)-鏈接裝載與庫(kù)>>一書中曾提到ld默認(rèn)使用的鏈接腳本
說(shuō)默認(rèn)在/usr/lib/ldscripts/下
結(jié)果我找了半天沒(méi)找到 我的系統(tǒng)是fedora 8
find / -name *lds* 找不到 找script也找不到 暈了
后來(lái)查了下發(fā)現(xiàn)可以用ld -verbose查看默認(rèn)的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;
........
后面略
這就奇怪了,那么這個(gè)lds到底在哪呢?
我們用find /usr/* |xargs grep "Script for -z combreloc"看看
結(jié)果 Binary file /usr/bin/ld matches 可見已經(jīng)集成到ld中了
readelf -P --string-dump=.rodata ld便可以找到
聯(lián)系客服