Bug 28370 - aarch64: relocation R_AARCH64_ADR_PREL_PG_HI21 against STT_GNU_IFUNC symbol `ifunc' isn't handled by elf64_aarch64_final_link_relocate
Summary: aarch64: relocation R_AARCH64_ADR_PREL_PG_HI21 against STT_GNU_IFUNC symbol `...
Status: UNCONFIRMED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-22 03:35 UTC by Fangrui Song
Modified: 2021-09-22 03:36 UTC (History)
0 users

See Also:
Host:
Target: aarch64-*
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fangrui Song 2021-09-22 03:35:13 UTC
GCC -fpic may generate direct relocations to take the address of an ifunc,
since an ifunc is not required to use the function attribute.
(GCC appears to use GOT when taking the address of an hidden __attribute__((ifunc(...))))

cat > ./a.c <<eof
__attribute__((visibility("hidden"))) void ifunc(void);
void (*addr(void))(void) { return ifunc; }
eof
cat > ./b.c <<eof
void impl(void) {}
void *resolver() { return impl; }
__attribute__((ifunc("resolver"), visibility("hidden"))) void ifunc(void);
eof

aarch64-linux-gnu-gcc -fpic -c a.c b.c

% ./ld-new -shared a.o b.o                                
./ld-new: a.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against STT_GNU_IFUNC symbol `ifunc' isn't handled by elf64_aarch64_final_link_relocate
a.o: in function `addr':
a.c:(.text+0x0): dangerous relocation: unsupported relocation
./ld-new: a.o: relocation R_AARCH64_ADD_ABS_LO12_NC against STT_GNU_IFUNC symbol `ifunc' isn't handled by elf64_aarch64_final_link_relocate
a.c:(.text+0x4): dangerous relocation: unsupported relocation


The x86-64 port handles the case.