I am trying to compile a asm code disassembled from GNU coreutils.
In the asm code, I see this:
extrn memchr@@GLIBC_2_0:near
extrn clock_gettime@@GLIBC_2_0:near
extrn attr_copy_fd@@ATTR_1_1:near
and I declare externs like this:
extern attr_copy_fd
extern clock_gettime
extern memchr
then asm like this:
nasm -f elf final.s -o final.o
gcc -W -o final final.o
And I got errors :
final.o: In function `loc_804BD8D':
final.s:(.text+0x2111): undefined reference to `attr_copy_fd'
final.o: In function `gettime':
final.s:(.text+0xdf06): undefined reference to `clock_gettime'
I think clock_gettime is defined in GLIBC and I don't know why linker can not find it(Other functions like memchr can be found by the linker)
What is worse, I don't know where is attr_copy_fd?
When building coreuitls from source code, you should link a static library libcoreutils.a
I tried to static link it as:
gcc -L/home/computereasy/work/lib/coreutils/coreutils-8.15/lib -lcoreutils -W -o final final.o
But nothing changed. and I don't think I should link libcoreutils.a because basically all the functions required in this binary from libcoreutils.a has been put into the disassemble code...
Could anyone give me some help on how to link the clock_gettime and attr_copy_fd ?
Thank you!