[RTEMS Project] #3740: Libld does not load incrementially linked object file
RTEMS trac
trac at rtems.org
Fri Apr 26 05:21:48 UTC 2019
#3740: Libld does not load incrementially linked object file
--------------------------+-------------------------
Reporter: Chris Johns | Owner: Chris Johns
Type: defect | Status: assigned
Priority: normal | Milestone: 5.1
Component: lib/dl | Version: 5
Severity: normal | Keywords:
Blocked By: | Blocking:
--------------------------+-------------------------
If separate object files have the same local symbol and are incrementally
linked `libdl` only uses the first symbol found.
The issue has been raised by Peter in a post to `devel`:
https://lists.rtems.org/pipermail/devel/2019-April/025623.html
The issue can be shown with:
{{{
$ cat foo.c
#include <stdio.h>
extern void foo(void);
void foo(void)
{
printf("FOO %s\n", "Foo 1");
}
$ cat bar.c
#include <stdio.h>
extern void bar(void);
void bar(void)
{
printf("BAR %s\n", "Bar 1");
}
$ arm-rtems5-gcc -march=armv7-a -mthumb -c foo.c
$ arm-rtems5-gcc -march=armv7-a -mthumb -c bar.c
$ arm-rtems5-ld -r -o fubar bar.o foo.o
$ arm-rtems5-readelf -s fubar
Symbol table '.symtab' contains 20 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00000000 0 SECTION LOCAL DEFAULT 1
2: 00000000 0 SECTION LOCAL DEFAULT 3
3: 00000000 0 SECTION LOCAL DEFAULT 4
4: 00000000 0 SECTION LOCAL DEFAULT 5
5: 00000000 0 SECTION LOCAL DEFAULT 6
6: 00000000 0 SECTION LOCAL DEFAULT 7
7: 00000000 0 FILE LOCAL DEFAULT ABS bar.c
8: 00000000 0 NOTYPE LOCAL DEFAULT 3 $d
9: 00000000 0 NOTYPE LOCAL DEFAULT 3 .LC0
10: 00000008 0 NOTYPE LOCAL DEFAULT 3 .LC1
11: 00000000 0 NOTYPE LOCAL DEFAULT 1 $t
12: 00000000 0 FILE LOCAL DEFAULT ABS foo.c
13: 00000010 0 NOTYPE LOCAL DEFAULT 3 $d
14: 00000010 0 NOTYPE LOCAL DEFAULT 3 .LC0
15: 00000018 0 NOTYPE LOCAL DEFAULT 3 .LC1
16: 0000001c 0 NOTYPE LOCAL DEFAULT 1 $t
17: 00000000 0 NOTYPE GLOBAL DEFAULT UND printf
18: 0000001d 28 FUNC GLOBAL DEFAULT 1 foo
19: 00000001 28 FUNC GLOBAL DEFAULT 1 bar
$ arm-rtems5-objdump --disassemble --source fubar
fubar: file format elf32-littlearm
Disassembly of section .text:
00000000 <bar>:
0: b580 push {r7, lr}
2: af00 add r7, sp, #0
4: f240 0100 movw r1, #0
8: f2c0 0100 movt r1, #0
c: f240 0000 movw r0, #0
10: f2c0 0000 movt r0, #0
14: f7ff fffe bl 0 <printf>
18: bf00 nop
1a: bd80 pop {r7, pc}
0000001c <foo>:
1c: b580 push {r7, lr}
1e: af00 add r7, sp, #0
20: f240 0100 movw r1, #0
24: f2c0 0100 movt r1, #0
28: f240 0000 movw r0, #0
2c: f2c0 0000 movt r0, #0
30: f7ff fffe bl 0 <printf>
34: bf00 nop
36: bd80 pop {r7, pc}
}}}
--
Ticket URL: <http://devel.rtems.org/ticket/3740>
RTEMS Project <http://www.rtems.org/>
RTEMS Project
More information about the bugs
mailing list