[PATCH] D27276: [ELF] Allow defined symbols to be assigned from linker script
Meador Inge via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 9 12:49:36 PST 2017
On Mon, Jan 09, 2017 at 02:08:49PM -0500, Rafael Avila de Espindola wrote:
> If there is a '.' in it it should not be ABS. Can you use ABSOLUTE(.) +
> 0x100?
That works. Thanks! I will apply that as a work around shortly.
Longer term, we have some bugs around section assignment for
linker-defined symbols. For example, lld gives:
$ cat test.ld
a = 1;
b = . + 2;
SECTIONS {
c = 3;
.text : {
*(.text)
d = 4;
}
e = . + 5;
.data : {
*(.data)
f = . + 6;
}
}
$ ./bin/ld.lld -o a.out test.o -T test.ld
./bin/ld.lld: warning: cannot find entry symbol _start; defaulting to 0x0
$ ./bin/llvm-objdump -t a.out
a.out: file format ELF64-x86-64
SYMBOL TABLE:
0000000000000000 *UND* 00000000
0000000000000001 *ABS* 00000000 a
0000000000000000 g F .text 00000000 foo
0000000000000002 .text 00000000 b
0000000000000003 *ABS* 00000000 c
0000000000000004 *ABS* 00000000 d
000000000000000d .text 00000000 e
0000000000000012 .data 00000000 f
GNU ld, gives:
$ ld -o a.out test.o -T test.ld
$ ./bin/llvm-objdump -t a.out
a.out: file format ELF64-x86-64
SYMBOL TABLE:
0000000000000000 *UND* 00000000
0000000000000000 l d .text 00000000 .text
0000000000000008 l d .data 00000000 .data
0000000000000000 l df *ABS* 00000000 test.c
0000000000000000 l df *ABS* 00000000
0000000000000002 *ABS* 00000000 b
0000000000000012 .data 00000000 f
0000000000000003 *ABS* 00000000 c
0000000000000004 .text 00000000 d
0000000000000000 g F .text 00000000 foo
0000000000000001 g *ABS* 00000000 a
000000000000000d *ABS* 00000000 e
A few observations from the above:
1. Symbols defined *inside* output section descriptors should live in
that section (e.g. `d`, `f`).
2. Symbols defined *outside* output section descriptors should be *ABS*
(e.g. `a`, `b`, `c`, and `e`).
Cheers,
--
Meador Inge
meadori at codesourcery.com
CodeSourcery / Mentor Embedded
More information about the llvm-commits
mailing list