aboutsummaryrefslogtreecommitdiff
path: root/tccelf.c
diff options
context:
space:
mode:
Diffstat (limited to 'tccelf.c')
-rw-r--r--tccelf.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/tccelf.c b/tccelf.c
index 7f1679d..df7375c 100644
--- a/tccelf.c
+++ b/tccelf.c
@@ -1052,7 +1052,8 @@ ST_FUNC void build_got_entries(TCCState *s1)
/* Proceed with PLT/GOT [entry] creation if any of the following
condition is met:
- it is an undefined reference (dynamic relocation needed)
- - symbol is absolute (probably created by tcc_add_symbol)
+ - symbol is absolute (probably created by tcc_add_symbol and
+ thus might be too far from application code)
- relocation requires a PLT/GOT (BUILD_GOTPLT_ENTRY or
ALWAYS_GOTPLT_ENTRY). */
if (sym->st_shndx != SHN_UNDEF &&
@@ -1060,6 +1061,15 @@ ST_FUNC void build_got_entries(TCCState *s1)
relocs_info[type].gotplt_entry == AUTO_GOTPLT_ENTRY)
continue;
+ /* Building a dynamic library but target is not capable of PC
+ relative PLT entries. It can thus only use PLT entries if
+ it expects one to be used (ALWAYS_GOTPLT_ENTRY). */
+ if (sym->st_shndx == SHN_UNDEF &&
+ s1->output_type == TCC_OUTPUT_DLL &&
+ !PCRELATIVE_DLLPLT &&
+ relocs_info[type].gotplt_entry == AUTO_GOTPLT_ENTRY)
+ continue;
+
#ifdef TCC_TARGET_X86_64
if (type == R_X86_64_PLT32 &&
ELFW(ST_VISIBILITY)(sym->st_other) != STV_DEFAULT) {