mirror of
https://github.com/mirror/tinycc.git
synced 2025-01-29 06:10:09 +08:00
Fix -static linking with uClibc
symbols are local when defined and referred to from the executable. Also, we need to relocate the .got section when this is a static link (our static linking effectively generates code as if this were a dynamic link with PLT and GOT, and then emulates the runtime loader).
This commit is contained in:
parent
adbe794a46
commit
05f6aa1ade
6
tccelf.c
6
tccelf.c
@ -1084,8 +1084,10 @@ ST_FUNC void build_got_entries(TCCState *s1)
|
|||||||
|
|
||||||
#ifdef TCC_TARGET_X86_64
|
#ifdef TCC_TARGET_X86_64
|
||||||
if ((type == R_X86_64_PLT32 || type == R_X86_64_PC32) &&
|
if ((type == R_X86_64_PLT32 || type == R_X86_64_PC32) &&
|
||||||
|
sym->st_shndx != SHN_UNDEF &&
|
||||||
(ELFW(ST_VISIBILITY)(sym->st_other) != STV_DEFAULT ||
|
(ELFW(ST_VISIBILITY)(sym->st_other) != STV_DEFAULT ||
|
||||||
ELFW(ST_BIND)(sym->st_info) == STB_LOCAL)) {
|
ELFW(ST_BIND)(sym->st_info) == STB_LOCAL ||
|
||||||
|
s1->output_type == TCC_OUTPUT_EXE)) {
|
||||||
rel->r_info = ELFW(R_INFO)(sym_index, R_X86_64_PC32);
|
rel->r_info = ELFW(R_INFO)(sym_index, R_X86_64_PC32);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1841,7 +1843,7 @@ static int final_sections_reloc(TCCState *s1)
|
|||||||
/* XXX: ignore sections with allocated relocations ? */
|
/* XXX: ignore sections with allocated relocations ? */
|
||||||
for(i = 1; i < s1->nb_sections; i++) {
|
for(i = 1; i < s1->nb_sections; i++) {
|
||||||
s = s1->sections[i];
|
s = s1->sections[i];
|
||||||
if (s->reloc && s != s1->got)
|
if (s->reloc && (s != s1->got || s1->static_link))
|
||||||
relocate_section(s1, s);
|
relocate_section(s1, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user