aboutsummaryrefslogtreecommitdiff
path: root/src/debug/elf/testdata
diff options
context:
space:
mode:
authorVictor Michel <victor@optimyze.cloud>2020-08-30 20:43:39 +0000
committerIan Lance Taylor <iant@golang.org>2020-08-31 18:42:38 +0000
commite01a226fadcac721e26c12921ca54388c7244d03 (patch)
treeb763dd5082943d7a970dd7114651249977ef56fb /src/debug/elf/testdata
parentf0c7e3e9463069f60b3d31696860f6fb75aa3e87 (diff)
downloadgo-e01a226fadcac721e26c12921ca54388c7244d03.tar.xz
debug/elf: support relocations relative to sections with non-zero addresses
commit 72ec930fa70c20ce69b21bf32a7916c04c2e9c2f 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. CL 195679 added further support for relocations, but explicitly encoded the original assumption that section addresses would be 0. This change removes that assumption: all relocations will now be properly computed based on the target symbol value even when that symbol is a section with a non-zero address. Typically, sections that are part of a LOAD program segment have non-zero addresses. For example, .debug_ranges relocations could be relative to .text, which usually has an address > 0. Fixes #40879 Change-Id: Ib0a616bb8b05d6c96d179b03ca33a10946fc5d59 GitHub-Last-Rev: 4200de732641995f3a4958a13a5c78f65b7eae50 GitHub-Pull-Request: golang/go#41038 Reviewed-on: https://go-review.googlesource.com/c/go/+/250559 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/debug/elf/testdata')
-rw-r--r--src/debug/elf/testdata/go-relocation-test-gcc930-ranges-no-rela-x86-64bin0 -> 5696 bytes
-rw-r--r--src/debug/elf/testdata/go-relocation-test-gcc930-ranges-with-rela-x86-64bin0 -> 7680 bytes
-rw-r--r--src/debug/elf/testdata/multiple-code-sections.c28
3 files changed, 28 insertions, 0 deletions
diff --git a/src/debug/elf/testdata/go-relocation-test-gcc930-ranges-no-rela-x86-64 b/src/debug/elf/testdata/go-relocation-test-gcc930-ranges-no-rela-x86-64
new file mode 100644
index 0000000000..c013f3e081
--- /dev/null
+++ b/src/debug/elf/testdata/go-relocation-test-gcc930-ranges-no-rela-x86-64
Binary files differ
diff --git a/src/debug/elf/testdata/go-relocation-test-gcc930-ranges-with-rela-x86-64 b/src/debug/elf/testdata/go-relocation-test-gcc930-ranges-with-rela-x86-64
new file mode 100644
index 0000000000..51e03aa7b0
--- /dev/null
+++ b/src/debug/elf/testdata/go-relocation-test-gcc930-ranges-with-rela-x86-64
Binary files differ
diff --git a/src/debug/elf/testdata/multiple-code-sections.c b/src/debug/elf/testdata/multiple-code-sections.c
new file mode 100644
index 0000000000..03b9d53ab9
--- /dev/null
+++ b/src/debug/elf/testdata/multiple-code-sections.c
@@ -0,0 +1,28 @@
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Build with:
+// gcc -g multiple-code-sections.c -Wl,--emit-relocs -Wl,--discard-none -Wl,-zmax-page-size=1 -fno-asynchronous-unwind-tables -o go-relocation-test-gcc930-ranges-with-rela-x86-64
+// gcc -g multiple-code-sections.c -Wl,-zmax-page-size=1 -fno-asynchronous-unwind-tables -o go-relocation-test-gcc930-ranges-no-rela-x86-64
+// Strip with:
+// strip --only-keep-debug \
+// --remove-section=.eh_frame \
+// --remove-section=.eh_frame_hdr \
+// --remove-section=.shstrtab \
+// --remove-section=.strtab \
+// --remove-section=.symtab \
+// --remove-section=.note.gnu.build-id \
+// --remove-section=.note.ABI-tag \
+// --remove-section=.dynamic \
+// --remove-section=.gnu.hash \
+// --remove-section=.interp \
+// --remove-section=.rodata
+__attribute__((section(".separate_section"))) // To get GCC to emit a DW_AT_ranges attribute for the CU.
+int func(void) {
+ return 0;
+}
+
+int main(int argc, char *argv[]) {
+ return 0;
+}