aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bfd/elfcode.h13
-rw-r--r--gas/testsuite/gas/i386/ilp32/ilp32.exp1
-rw-r--r--gas/testsuite/gas/i386/ilp32/reloc-2.l4
-rw-r--r--gas/testsuite/gas/i386/ilp32/reloc-2.s7
-rw-r--r--gas/testsuite/gas/i386/ilp32/reloc64.d3
-rw-r--r--gas/testsuite/gas/i386/ilp32/reloc64.l14
-rw-r--r--gas/testsuite/gas/i386/ilp32/reloc64.s3
7 files changed, 36 insertions, 9 deletions
diff --git a/bfd/elfcode.h b/bfd/elfcode.h
index c3ab053..4d4cb68 100644
--- a/bfd/elfcode.h
+++ b/bfd/elfcode.h
@@ -997,6 +997,19 @@ elf_write_relocs (bfd *abfd, asection *sec, void *data)
return;
}
+#if defined(BFD64) && ARCH_SIZE == 32
+ if (rela_hdr->sh_type == SHT_RELA
+ && ptr->howto->bitsize > 32
+ && ptr->addend - INT32_MIN > UINT32_MAX)
+ {
+ _bfd_error_handler (_("%pB: %pA+%"BFD_VMA_FMT"x: "
+ "relocation addend %"BFD_VMA_FMT"x too large"),
+ abfd, sec, ptr->address, ptr->addend);
+ *failedp = true;
+ bfd_set_error (bfd_error_bad_value);
+ }
+#endif
+
src_rela.r_offset = ptr->address + addr_offset;
src_rela.r_info = ELF_R_INFO (n, ptr->howto->type);
src_rela.r_addend = ptr->addend;
diff --git a/gas/testsuite/gas/i386/ilp32/ilp32.exp b/gas/testsuite/gas/i386/ilp32/ilp32.exp
index d1bb96c..c2ff5e3 100644
--- a/gas/testsuite/gas/i386/ilp32/ilp32.exp
+++ b/gas/testsuite/gas/i386/ilp32/ilp32.exp
@@ -38,6 +38,7 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_x32_check] &
}
run_list_test "reloc64" "--defsym _bad_=1"
+ run_list_test "reloc-2"
set ASFLAGS "$old_ASFLAGS"
}
diff --git a/gas/testsuite/gas/i386/ilp32/reloc-2.l b/gas/testsuite/gas/i386/ilp32/reloc-2.l
new file mode 100644
index 0000000..9e89145
--- /dev/null
+++ b/gas/testsuite/gas/i386/ilp32/reloc-2.l
@@ -0,0 +1,4 @@
+.*: \.text\+2:.*addend.*too large.*
+.*: \.text\+b:.*addend.*too large.*
+.*: Assembler messages:
+.*: Fatal error: .*
diff --git a/gas/testsuite/gas/i386/ilp32/reloc-2.s b/gas/testsuite/gas/i386/ilp32/reloc-2.s
new file mode 100644
index 0000000..f9035a8
--- /dev/null
+++ b/gas/testsuite/gas/i386/ilp32/reloc-2.s
@@ -0,0 +1,7 @@
+ .text
+_start:
+ movabs $x+0x123456789, %rax
+ movabs x+0x123456789, %eax
+
+ .data
+ .quad x+0x123456789
diff --git a/gas/testsuite/gas/i386/ilp32/reloc64.d b/gas/testsuite/gas/i386/ilp32/reloc64.d
index 78ca3fd..e2c461f 100644
--- a/gas/testsuite/gas/i386/ilp32/reloc64.d
+++ b/gas/testsuite/gas/i386/ilp32/reloc64.d
@@ -61,7 +61,8 @@ Disassembly of section \.text:
.*[ ]+R_X86_64_TPOFF32[ ]+xtrn
.*[ ]+R_X86_64_TPOFF32[ ]+xtrn
.*[ ]+R_X86_64_TPOFF32[ ]+xtrn
-.*[ ]+R_X86_64_64[ ]+xtrn\+0x1
+.*[ ]+R_X86_64_64[ ]+xtrn\+0x7fffffff
+.*[ ]+R_X86_64_64[ ]+xtrn\-0x80000000
Disassembly of section \.data:
#...
.*[ ]+R_X86_64_32[ ]+xtrn
diff --git a/gas/testsuite/gas/i386/ilp32/reloc64.l b/gas/testsuite/gas/i386/ilp32/reloc64.l
index 9643e67..aad4c58 100644
--- a/gas/testsuite/gas/i386/ilp32/reloc64.l
+++ b/gas/testsuite/gas/i386/ilp32/reloc64.l
@@ -51,17 +51,17 @@
.*:175: Error: .*
.*:176: Error: .*
.*:177: Error: .*
-.*:189: Error: .*
-.*:192: Error: .* too large for field of 4 bytes at .*
+.*:190: Error: .*
.*:193: Error: .* too large for field of 4 bytes at .*
.*:194: Error: .* too large for field of 4 bytes at .*
.*:195: Error: .* too large for field of 4 bytes at .*
-.*:196: Error: .* too large for field of 2 bytes at .*
-.*:196: Error: .* too large for field of 1 byte at .*
+.*:196: Error: .* too large for field of 4 bytes at .*
.*:197: Error: .* too large for field of 2 bytes at .*
.*:197: Error: .* too large for field of 1 byte at .*
-.*:200: Error: .* too large for field of 4 bytes at .*
-.*:201: Error: .* too large for field of 2 bytes at .*
+.*:198: Error: .* too large for field of 2 bytes at .*
+.*:198: Error: .* too large for field of 1 byte at .*
+.*:201: Error: .* too large for field of 4 bytes at .*
.*:202: Error: .* too large for field of 2 bytes at .*
-.*:203: Error: .* too large for field of 1 byte at .*
+.*:203: Error: .* too large for field of 2 bytes at .*
.*:204: Error: .* too large for field of 1 byte at .*
+.*:205: Error: .* too large for field of 1 byte at .*
diff --git a/gas/testsuite/gas/i386/ilp32/reloc64.s b/gas/testsuite/gas/i386/ilp32/reloc64.s
index 9f5990a..db2d2ac 100644
--- a/gas/testsuite/gas/i386/ilp32/reloc64.s
+++ b/gas/testsuite/gas/i386/ilp32/reloc64.s
@@ -178,7 +178,8 @@ bad .byte xtrn@tpoff
.text
mov xtrn@tpoff (%rbx), %eax
- movabsq $xtrn - 4294967295, %rbp
+ movabsq $xtrn + 0x7fffffff, %rbx
+ movabsq $xtrn - 0x80000000, %rbp
.data
.quad xtrn