mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1839740 - Rename the symbol by elfhack to point to the ELF header. r=firefox-build-system-reviewers,andi
Elfhack acts as a linker, and it uses the `elf_header` symbol to point at the ELF header in the injected code that applies relocations. Both GNU ld and lld expose a `__ehdr_start` symbol with the same meaning, so rename the `elf_header` symbol for compatibility. This will allow to reuse the code in the upcoming replacement for elfhack. Differential Revision: https://phabricator.services.mozilla.com/D187088
This commit is contained in:
parent
62b0896fb2
commit
1da6d16d6d
@ -474,8 +474,8 @@ class ElfRelHackCode_Section : public ElfSection {
|
||||
addr = relhack_section.getAddr();
|
||||
} else if (strcmp(name, "relhack_end") == 0) {
|
||||
addr = relhack_section.getAddr() + relhack_section.getSize();
|
||||
} else if (strcmp(name, "elf_header") == 0) {
|
||||
// TODO: change this ungly hack to something better
|
||||
} else if (strcmp(name, "__ehdr_start") == 0) {
|
||||
// TODO: change this ugly hack to something better
|
||||
ElfSection* ehdr = parent.getSection(1)->getPrevious()->getPrevious();
|
||||
addr = ehdr->getAddr();
|
||||
} else if (strcmp(name, "original_init") == 0) {
|
||||
|
@ -69,7 +69,7 @@ extern __attribute__((visibility("hidden"))) void original_init(int argc,
|
||||
|
||||
extern __attribute__((visibility("hidden"))) Elf_Addr relhack[];
|
||||
extern __attribute__((visibility("hidden"))) Elf_Addr relhack_end[];
|
||||
extern __attribute__((visibility("hidden"))) Elf_Ehdr elf_header;
|
||||
extern __attribute__((visibility("hidden"))) Elf_Ehdr __ehdr_start;
|
||||
|
||||
extern __attribute__((visibility("hidden"))) int (*mprotect_cb)(void* addr,
|
||||
size_t len,
|
||||
@ -82,8 +82,8 @@ static inline __attribute__((always_inline)) void do_relocations(void) {
|
||||
Elf_Addr* ptr;
|
||||
for (Elf_Addr* entry = relhack; entry < relhack_end; entry++) {
|
||||
if ((*entry & 1) == 0) {
|
||||
ptr = (Elf_Addr*)((intptr_t)&elf_header + *entry);
|
||||
*ptr += (intptr_t)&elf_header;
|
||||
ptr = (Elf_Addr*)((intptr_t)&__ehdr_start + *entry);
|
||||
*ptr += (intptr_t)&__ehdr_start;
|
||||
} else {
|
||||
size_t remaining = (8 * sizeof(Elf_Addr) - 1);
|
||||
Elf_Addr bits = *entry;
|
||||
@ -92,7 +92,7 @@ static inline __attribute__((always_inline)) void do_relocations(void) {
|
||||
remaining--;
|
||||
ptr++;
|
||||
if (bits & 1) {
|
||||
*ptr += (intptr_t)&elf_header;
|
||||
*ptr += (intptr_t)&__ehdr_start;
|
||||
}
|
||||
} while (bits);
|
||||
ptr += remaining;
|
||||
|
Loading…
Reference in New Issue
Block a user