Skip to content

Commit 7ae39e2

Browse files
Egeyar Bagciogluccoutant
authored andcommitted
Check whether symbols with MOVW_.ABS relocations require PLT entries (aarch64).
2019-02-19 Egeyar Bagcioglu <[email protected]> gold/ PR gold/23870 * aarch64.cc (Target_aarch64::Scan::global): Check if a symbol with R_AARCH64_MOVW_.ABS_* relocations requires a PLT entry. * testsuite/Makefile.am: Add aarch64_pr23870 test case. * testsuite/Makefile.in: Regenerate. * testsuite/aarch64_pr23870_bar.c: New file. * testsuite/aarch64_pr23870_foo.c: New file. * testsuite/aarch64_pr23870_main.S: New file.
1 parent abaeb15 commit 7ae39e2

File tree

7 files changed

+146
-44
lines changed

7 files changed

+146
-44
lines changed

gold/ChangeLog

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2019-02-19 Egeyar Bagcioglu <[email protected]>
2+
3+
PR gold/23870
4+
* aarch64.cc (Target_aarch64::Scan::global): Check if a symbol with
5+
R_AARCH64_MOVW_.ABS_* relocations requires a PLT entry.
6+
* testsuite/Makefile.am: Add aarch64_pr23870 test case.
7+
* testsuite/Makefile.in: Regenerate.
8+
* testsuite/aarch64_pr23870_bar.c: New file.
9+
* testsuite/aarch64_pr23870_foo.c: New file.
10+
* testsuite/aarch64_pr23870_main.S: New file.
11+
112
2019-02-12 Nick Clifton <[email protected]>
213

314
* po/fr.po: Updated French translation.

gold/aarch64.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6496,6 +6496,17 @@ Target_aarch64<size, big_endian>::Scan::global(
64966496
gold_error(_("%s: unsupported reloc %u in pos independent link."),
64976497
object->name().c_str(), r_type);
64986498
}
6499+
// Make a PLT entry if necessary.
6500+
if (gsym->needs_plt_entry())
6501+
{
6502+
target->make_plt_entry(symtab, layout, gsym);
6503+
// Since this is not a PC-relative relocation, we may be
6504+
// taking the address of a function. In that case we need to
6505+
// set the entry in the dynamic symbol table to the address of
6506+
// the PLT entry.
6507+
if (gsym->is_from_dynobj() && !parameters->options().shared())
6508+
gsym->set_needs_dynsym_value();
6509+
}
64996510
break;
65006511

65016512
case elfcpp::R_AARCH64_LD_PREL_LO19: // 273

gold/testsuite/Makefile.am

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3285,6 +3285,26 @@ pr22266: pr22266_main.o pr22266_ar.o gcctestdir/ld
32853285
pr22266_ar.o: pr22266_a.o gcctestdir/ld
32863286
gcctestdir/ld -r -T $(srcdir)/pr22266_script.t -o $@ pr22266_a.o
32873287

3288+
if DEFAULT_TARGET_AARCH64
3289+
3290+
check_PROGRAMS += aarch64_pr23870
3291+
aarch64_pr23870_SOURCES = aarch64_pr23870_foo.c
3292+
aarch64_pr23870_DEPENDENCIES = \
3293+
gcctestdir/ld gcctestdir/as aarch64_pr23870_main.o \
3294+
aarch64_pr23870_foo.o aarch64_pr23870_bar.so
3295+
aarch64_pr23870_LDFLAGS = -Wl,-R,. -L. -Wl,-l:aarch64_pr23870_bar.so
3296+
aarch64_pr23870_LDADD = aarch64_pr23870_main.o
3297+
aarch64_pr23870_main.o: aarch64_pr23870_main.S
3298+
$(COMPILE) -c -o $@ $<
3299+
aarch64_pr23870_foo.o: aarch64_pr23870_foo.c
3300+
$(COMPILE) -c -o $@ $<
3301+
aarch64_pr23870_bar.o: aarch64_pr23870_bar.c
3302+
$(COMPILE) -c -fPIC -o $@ $<
3303+
aarch64_pr23870_bar.so: aarch64_pr23870_bar.o
3304+
$(COMPILE) -shared -o $@ $<
3305+
3306+
endif DEFAULT_TARGET_AARCH64
3307+
32883308
endif GCC
32893309
endif NATIVE_LINKER
32903310

gold/testsuite/Makefile.in

Lines changed: 77 additions & 44 deletions
Large diffs are not rendered by default.

gold/testsuite/aarch64_pr23870_bar.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
void bar (void);
2+
3+
void bar ()
4+
{
5+
return;
6+
}

gold/testsuite/aarch64_pr23870_foo.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
void foo (void (*bar)(void));
2+
3+
void foo (void (*bar)(void))
4+
{
5+
bar();
6+
}

gold/testsuite/aarch64_pr23870_main.S

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
.text
3+
.globl main
4+
.type main,#function
5+
main:
6+
stp x29, x30, [sp,#-16]!
7+
mov x29, sp
8+
movz x0, #:abs_g3:bar
9+
movk x0, #:abs_g2_nc:bar
10+
movk x0, #:abs_g1_nc:bar
11+
movk x0, #:abs_g0_nc:bar
12+
add x0, x0, #0x0
13+
bl foo
14+
ldp x29, x30, [sp],#16
15+
ret

0 commit comments

Comments
 (0)