aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/reloc.c7
-rw-r--r--ld/ChangeLog8
-rw-r--r--ld/testsuite/ld-x86-64/pe-x86-64-5.obj.bz2bin0 -> 685 bytes
-rw-r--r--ld/testsuite/ld-x86-64/pe-x86-64-5.od34
-rw-r--r--ld/testsuite/ld-x86-64/pe-x86-64-5.rd19
-rw-r--r--ld/testsuite/ld-x86-64/pe-x86-64.exp10
7 files changed, 84 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 38123b4..eaeb47d 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2021-01-12 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/27171
+ * reloc.c (bfd_perform_relocation): Adjust R_AMD64_DIR64 and
+ R_AMD64_DIR32 relocations for PE/x86-64 inputs.
+
2021-01-11 H.J. Lu <hongjiu.lu@intel.com>
PR ld/27173
diff --git a/bfd/reloc.c b/bfd/reloc.c
index 46c996f..4f4b95a 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -921,6 +921,13 @@ space consuming. For each target:
if (howto->type >= R_AMD64_PCRLONG_1
&& howto->type <= R_AMD64_PCRLONG_5)
relocation -= (bfd_vma)(howto->type - R_AMD64_PCRLONG);
+ else if (howto->type == R_AMD64_DIR64
+ || howto->type == R_AMD64_DIR32)
+ {
+ bfd_vma val = read_reloc (abfd, (bfd_byte *) data + octets,
+ howto);
+ relocation -= val & howto->src_mask;
+ }
}
/* FIXME: This overflow checking is incomplete, because the value
diff --git a/ld/ChangeLog b/ld/ChangeLog
index bedd0fa..a4b0ea6 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,11 @@
+2021-01-12 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/27171
+ * testsuite/ld-x86-64/pe-x86-64-5.obj.bz2: New file.
+ * testsuite/ld-x86-64/pe-x86-64-5.od: Likewise.
+ * testsuite/ld-x86-64/pe-x86-64-5.rd: Likewise.
+ * testsuite/ld-x86-64/pe-x86-64.exp: Run PR ld/27171 test.
+
2021-01-11 H.J. Lu <hongjiu.lu@intel.com>
PR ld/27173
diff --git a/ld/testsuite/ld-x86-64/pe-x86-64-5.obj.bz2 b/ld/testsuite/ld-x86-64/pe-x86-64-5.obj.bz2
new file mode 100644
index 0000000..bb0d38c
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pe-x86-64-5.obj.bz2
Binary files differ
diff --git a/ld/testsuite/ld-x86-64/pe-x86-64-5.od b/ld/testsuite/ld-x86-64/pe-x86-64-5.od
new file mode 100644
index 0000000..8a4f4a6
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pe-x86-64-5.od
@@ -0,0 +1,34 @@
+
+.*: +file format .*
+
+SYMBOL TABLE:
+0+402014 g .bss 0000000000000000 non_initdummy
+0+402010 g .data 0000000000000000 initdummy
+0+401000 g .text\$mn 0000000000000000 begin
+0+402012 g .bss 0000000000000000 __bss_start
+0+402000 g .data 0000000000000000 Struct
+0+402011 g .data 0000000000000000 initializedVar
+0+402012 g .data 0000000000000000 _edata
+0+402018 g .bss 0000000000000000 _end
+0+402015 g .bss 0000000000000000 non_initialVar
+
+
+
+Disassembly of section .text\$mn:
+
+0+401000 <begin>:
+ +[a-f0-9]+: 66 90 xchg %ax,%ax
+ +[a-f0-9]+: cc int3
+ +[a-f0-9]+: 48 8d 05 07 10 00 00 lea 0x1007\(%rip\),%rax # 402011 <initializedVar>
+ +[a-f0-9]+: 48 3b 05 ef 0f 00 00 cmp 0xfef\(%rip\),%rax # 402000 <Struct>
+ +[a-f0-9]+: 74 01 je 401014 <begin\+0x14>
+ +[a-f0-9]+: cc int3
+ +[a-f0-9]+: 48 8d 05 fa 0f 00 00 lea 0xffa\(%rip\),%rax # 402015 <non_initialVar>
+ +[a-f0-9]+: 48 3b 05 e6 0f 00 00 cmp 0xfe6\(%rip\),%rax # 402008 <Struct\+0x8>
+ +[a-f0-9]+: 74 01 je 401025 <begin\+0x25>
+ +[a-f0-9]+: cc int3
+ +[a-f0-9]+: 66 ba 80 00 mov \$0x80,%dx
+ +[a-f0-9]+: b0 12 mov \$0x12,%al
+ +[a-f0-9]+: ee out %al,\(%dx\)
+ +[a-f0-9]+: c3 ret
+#pass
diff --git a/ld/testsuite/ld-x86-64/pe-x86-64-5.rd b/ld/testsuite/ld-x86-64/pe-x86-64-5.rd
new file mode 100644
index 0000000..8370665
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pe-x86-64-5.rd
@@ -0,0 +1,19 @@
+
+Symbol table '.symtab' contains 10 entries:
+ Num: Value Size Type Bind Vis Ndx Name
+ +[a-f0-9]+: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
+ +[a-f0-9]+: 0000000000402014 0 NOTYPE GLOBAL DEFAULT 3 non_initdummy
+ +[a-f0-9]+: 0000000000402010 0 NOTYPE GLOBAL DEFAULT 2 initdummy
+ +[a-f0-9]+: 0000000000401000 0 NOTYPE GLOBAL DEFAULT 1 begin
+ +[a-f0-9]+: 0000000000402012 0 NOTYPE GLOBAL DEFAULT 3 __bss_start
+ +[a-f0-9]+: 0000000000402000 0 NOTYPE GLOBAL DEFAULT 2 Struct
+ +[a-f0-9]+: 0000000000402011 0 NOTYPE GLOBAL DEFAULT 2 initializedVar
+ +[a-f0-9]+: 0000000000402012 0 NOTYPE GLOBAL DEFAULT 2 _edata
+ +[a-f0-9]+: 0000000000402018 0 NOTYPE GLOBAL DEFAULT 3 _end
+ +[a-f0-9]+: 0000000000402015 0 NOTYPE GLOBAL DEFAULT 3 non_initialVar
+
+Hex dump of section '.data':
+ 0x00402000 11204000 00000000 15204000 00000000 . @...... @.....
+ 0x00402010 aa55 .U
+
+#pass
diff --git a/ld/testsuite/ld-x86-64/pe-x86-64.exp b/ld/testsuite/ld-x86-64/pe-x86-64.exp
index e81a0b4..ccfcdfa 100644
--- a/ld/testsuite/ld-x86-64/pe-x86-64.exp
+++ b/ld/testsuite/ld-x86-64/pe-x86-64.exp
@@ -63,4 +63,14 @@ run_ld_link_tests [list \
{{objdump {-dw --sym} pe-x86-64-4.od}} \
"pe-x86-64-4" \
] \
+ [list \
+ "Build pe-x86-64-5" \
+ "-m elf_x86_64 --entry=begin" \
+ "" \
+ "" \
+ {pe-x86-64-5.obj.bz2 } \
+ {{objdump {-dw --sym} pe-x86-64-5.od} \
+ {readelf {-s -x .data} pe-x86-64-5.rd}} \
+ "pe-x86-64-5" \
+ ] \
]