-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
debug/elf: handle sections with non-zero addresses when applying relo…
…cations commit 72ec930 added basic support for relocations, but assumed that the symbol value would be 0, likely because .debug_info always has address == 0 in the ELF section headers. commit df855da added further support for relocations, but explicitly encoded the original assumption that section addresses would be 0. This commit removes that assumption, and adds support for relocations relative to sections that have non-zero addresses. Typically, sections that are part of a LOAD program segment are such sections. For example, .debug_ranges relocations could be relative to .text, which usually has an address > 0. This addresses golang#40879, causing relocations for .debug_ranges to be incorrectly applied.
- Loading branch information
Showing
6 changed files
with
93 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+21.4 KB
src/debug/elf/testdata/go-relocation-test-gcc930-ranges-no-rela-x86-64
Binary file not shown.
Binary file added
BIN
+23.4 KB
src/debug/elf/testdata/go-relocation-test-gcc930-ranges-with-rela-x86-64
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Build with: | ||
// gcc -g multiple-code-sections.c multiple-code-sections.ld -Wl,--emit-relocs -Wl,--discard-none -o go-relocation-test-gcc930-ranges-with-rela-x86-64 | ||
// gcc -g multiple-code-sections.c multiple-code-sections.ld -o go-relocation-test-gcc930-ranges-no-rela-x86-64 | ||
__attribute__((section(".coffee_section"))) | ||
int coffee(void) { | ||
return 0; | ||
} | ||
|
||
int main(int argc, char *argv[]) { | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
SECTIONS | ||
{ | ||
. = 0xC0FFEE; | ||
.coffee_section : {} | ||
} |