This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Re: How to create a library which contains absolute addresses of exported functions?
- From: "PRC" <panruochen at gmail dot com>
- To: "DJ Delorie" <dj at redhat dot com>
- Cc: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Thu, 6 Mar 2008 15:40:48 +0800
- Subject: Re: Re: How to create a library which contains absolute addresses of exported functions?
- References: <200803061132055669808@gmail.com>, <xn4pbka52u.fsf@greed.delorie.com>
It can't work on some gcc.
`1.c'
-----------------------
int main()
{
printf("This is function main!\n");
}
`2.S'
-----------------------
.globl printf
printf = 0x80001600
`link.xn'
-----------------------
OUTPUT_ARCH(mips)
ENTRY(main)
SECTIONS
{
.text 0x80051000 :
{
*(.text)
*(.rodata*)
}
.data :
{
*(.data)
*(.sdata)
}
.sbss :
{
*(.sbss)
*(.scommon)
}
.bss :
{
*(.bss)
*(COMMON)
}
}
sde-gcc -W -mips32r2 -EL -c -mno-abicalls -fno-pic -G0 -o 1.o 1.c
1.c:5:2: warning: no newline at end of file
sde-gcc -W -mips32r2 -EL -c -mno-abicalls -fno-pic -G0 -o 2.o 2.S
sde-ld -T link.xn -EL 1.o 2.o -o a.out
1.o: In function `main':
1.c:(.text+0x18): relocation truncated to fit: R_MIPS_26 against `printf'
The gcc core is
-------------------
Reading specs from /usr/local/sde-mips/bin/../lib/gcc/sde/3.4.4/specs
Configured with: /cygdrive/c/releasetool.tmp/bank-20070207-1902/B-i386-cygwin/toolchain/mipssde-6.06.00/configure --target=sde --prefix=/usr/local/sde6 --enable-languages=c,c++ --without-newlib --disable-shared --disable-nls --disable-tui --disable-multilib
Thread model: mipssde
gcc version 3.4.4 mipssde-6.06.00-20070207
And it works on another gcc whose core is
------------------------
Reading specs from /usr/local/lib/gcc/mips-elf/3.4.0-macraigor1/specs
Configured with: /rel/share/gnu/src/gcc-3.4.0-macraigor1/configure --host=i686-pc-cygwin --target=mips-elf --disable-nls --with-stabs --disable-install-libiberty --disable-install-libbfd --disable-dependency-tracking --enable-64-bit-bfd --enable-languages=c,c++ --with-gnu-as --with-gnu-ld
Thread model: single
gcc version 3.4.0-macraigor1
>You can create a .S file that has entries like this:
>
> .global strcpy
>strcpy = 0x80001600
> .global vsprintf
>vsprintf = 0x80002290
> .global memmove
>memmove = 0x80001e50
>
>If you assemble that and put it in your library, it will do the same
>thing, without the linker script or .c file.
>
>You could do one symbol per .S file if you wanted to.