[LLVMdev] [lld] ELF weak aliases
shankare at codeaurora.org
shankare at codeaurora.org
Tue Jan 8 20:56:13 PST 2013
Hi Michael,
Does ELF support aliasing ?
How is the relationship captured in ELF symbol table, that one symbol is a
alias of another symbol ?
> Note that __stdout_used is the last symbol in the .rodata section.
> This means that the reader assigns the data (16 bytes of 0) to
> __stdout_used. Because dummy_file and the other __stdx_used symbols
> come before it, they end up in the right place in the final file.
Did you change the Reader too ?
The Reader doesnot allocate any space for __stdout_used. The size of the
current symbol = (value of next symbol - current symbol). In this case its
zero.
>
> This works great until another object file provides a definition of
> __stdout_used. The weak definition of it gets totally removed, meaning
> so does the content for the other __stdx_used symbols.
When the other object provides a definition for __stdout_used, the atom
gets the property of the other object which defines the atom isnt it, and
so as the ordinal too riht ?
Couldnt follow how did the others move ?
This is what I see with binutils/ld :-
$cat 1.c
#include "stdio_impl.h"
static FILE *const dummy_file = 0;
weak_alias(dummy_file, __stdin_used);
weak_alias(dummy_file, __stdout_used);
weak_alias(dummy_file, __stderr_used);
$cat 2.c
int __stdout_used = 10;
$readelf -s 1.o | grep -E 'used|dummy_file'
6: 0000000000000000 8 OBJECT LOCAL DEFAULT 4 dummy_file
9: 0000000000000000 8 OBJECT WEAK DEFAULT 4 __stdin_used
10: 0000000000000000 8 OBJECT WEAK DEFAULT 4 __stdout_used
11: 0000000000000000 8 OBJECT WEAK DEFAULT 4 __stderr_used
$readelf -s 2.o | grep -E 'used|dummy_file'
7: 0000000000000000 4 OBJECT GLOBAL DEFAULT 2 __stdout_used
$ld 1.o 2.o
ld: warning: cannot find entry symbol _start; defaulting to 00000000004000e8
$readelf -s a.out | grep -E 'used|dummy_file'
5: 00000000004000e8 8 OBJECT LOCAL DEFAULT 1 dummy_file
7: 00000000006000f0 4 OBJECT GLOBAL DEFAULT 2 __stdout_used
8: 00000000004000e8 8 OBJECT WEAK DEFAULT 1 __stdin_used
13: 00000000004000e8 8 OBJECT WEAK DEFAULT 1 __stderr_used
Thanks
Shankar Easwaran
More information about the llvm-dev
mailing list