diff options
| -rw-r--r-- | arm-link.c | 1 | ||||
| -rw-r--r-- | arm64-link.c | 1 | ||||
| -rw-r--r-- | c67-link.c | 1 | ||||
| -rw-r--r-- | i386-link.c | 1 | ||||
| -rw-r--r-- | tccelf.c | 12 | ||||
| -rw-r--r-- | x86_64-link.c | 1 |
6 files changed, 16 insertions, 1 deletions
@@ -15,6 +15,7 @@ #define ELF_PAGE_SIZE 0x1000 #define HAVE_SECTION_RELOC +#define PCRELATIVE_DLLPLT 1 enum float_abi { ARM_SOFTFP_FLOAT, diff --git a/arm64-link.c b/arm64-link.c index 9e5a873..c22c20a 100644 --- a/arm64-link.c +++ b/arm64-link.c @@ -14,6 +14,7 @@ #define ELF_PAGE_SIZE 0x1000 #define HAVE_SECTION_RELOC +#define PCRELATIVE_DLLPLT 1 #else /* !TARGET_DEFS_ONLY */ @@ -15,6 +15,7 @@ #define ELF_PAGE_SIZE 0x1000 #define HAVE_SECTION_RELOC +#define PCRELATIVE_DLLPLT 0 #else /* !TARGET_DEFS_ONLY */ diff --git a/i386-link.c b/i386-link.c index c972481..a7ef73f 100644 --- a/i386-link.c +++ b/i386-link.c @@ -15,6 +15,7 @@ #define ELF_PAGE_SIZE 0x1000 #define HAVE_SECTION_RELOC +#define PCRELATIVE_DLLPLT 0 #else /* !TARGET_DEFS_ONLY */ @@ -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) { diff --git a/x86_64-link.c b/x86_64-link.c index 8769b3a..25ae29c 100644 --- a/x86_64-link.c +++ b/x86_64-link.c @@ -15,6 +15,7 @@ #define ELF_PAGE_SIZE 0x200000 #define HAVE_SECTION_RELOC +#define PCRELATIVE_DLLPLT 1 #else /* !TARGET_DEFS_ONLY */ |
