The test is on 32-bit Linux, x86.
Suppose in my assembly program final.s
, I have to load some library symbols, say, stdin@@GLIBC_2.0
, and I want to load these symbols in a fixed address.
So following instructions in this question, I did this:
echo ""stdin@@GLIBC_2.0" = 0x080a7390;" > symbolfile
echo ""stdin@GLIBC_2.0 (4)" = 0x080a7390;" >> symbolfile
gcc -Wl,--just-symbols=symbolfile final.s -g
And when I checked the output of symbol table, I got this:
readelf -s a.out | grep stdin
53: 080a7390 4 OBJECT GLOBAL DEFAULT ABS stdin@@GLIBC_2.0
17166: 080a7390 0 NOTYPE GLOBAL DEFAULT ABS stdin@GLIBC_2.0 (4)
And comparing to a common ELF biary that requires stdin
symbol:
readelf -s hello.out | grep stdin
17199: 0838b8c4 4 OBJECT GLOBAL DEFAULT 25 stdin@@GLIBC_2.0
52: 0838b8c4 4 OBJECT GLOBAL DEFAULT 25 stdin@GLIBC_2.0 (4)
So an obvious difference I found is that the Ndx
column, say, the section number of my fixed position symbols are ABS
. Please check the references here.
When executing the a.out
, it throws a segmentation fault
error.
So my question is, how to set the section number of the symbol fixed position?