This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] PR ld/17618: Check PC-relative offset overflow in PLT entry
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Binutils <binutils at sourceware dot org>
- Date: Wed, 9 Aug 2017 15:08:54 -0700
- Subject: Re: [PATCH] PR ld/17618: Check PC-relative offset overflow in PLT entry
- Authentication-results: sourceware.org; auth=none
- References: <20141118191113.GA2298@intel.com> <20141120213713.GA5521@intel.com>
On Thu, Nov 20, 2014 at 1:37 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
> On Tue, Nov 18, 2014 at 11:11:13AM -0800, H.J. Lu wrote:
>> Hi,
>>
>> I checked in this patch to check PC-relative offset overflow in pushq
>> instruction in x86-64 PLT entry.
>>
>>
>
> I checked in this patch to avoid running pr17618.d test on x32 since
> it needs more than 4GB memory.
>
> H.J.
> ---
> diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
> index f959d55..8e69a89 100644
> --- a/ld/testsuite/ChangeLog
> +++ b/ld/testsuite/ChangeLog
> @@ -1,5 +1,9 @@
> 2014-11-20 H.J. Lu <hongjiu.lu@intel.com>
>
> + * ld-x86-64/pr17618.d: Don't run on x32.
> +
> +2014-11-20 H.J. Lu <hongjiu.lu@intel.com>
> +
> * ld-x86-64/plt-main1.rd: Updated for x32.
> * ld-x86-64/plt-main2.rd: Likewise.
> * ld-x86-64/plt-main3.rd: Likewise.
> diff --git a/ld/testsuite/ld-x86-64/pr17618.d b/ld/testsuite/ld-x86-64/pr17618.d
> index e640b40..b090aa0 100644
> --- a/ld/testsuite/ld-x86-64/pr17618.d
> +++ b/ld/testsuite/ld-x86-64/pr17618.d
> @@ -1,4 +1,5 @@
> #name: PLT PC-relative offset overflow check
> #as: --64
> #ld: -shared -melf_x86_64
> +#notarget: x86_64-*-linux*-gnux32
> #error: .*PC-relative offset overflow in PLT entry for `bar'
I checked in this patch to run PR ld/17618 test only with 64-bit
ELF linker.
--
H.J.
From 978c05401b0f0ac7a94cca7db19b1dec0c5bd698 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Wed, 9 Aug 2017 15:04:05 -0700
Subject: [PATCH] Run PR ld/17618 test only with 64-bit ELF linker
PR ld/17618 test requires 64-bit linker to run. Set LD_CLASS to "64bit"
for 64-bit ELF linker and run PR ld/17618 test only if $LD_CLASS is
"64bit". More checks can be added to support 64-bit linkers in non-ELF
format.
* testsuite/config/default.exp (LD_CLASS): New. Set to "64bit"
for 64-bit ELF linker.
* testsuite/ld-x86-64/pr17618.d (#notarget): Removed.
* testsuite/ld-x86-64/x86-64.exp: Run pr17618 only for 64-bit
linker.
---
ld/ChangeLog | 8 ++++++++
ld/testsuite/config/default.exp | 10 ++++++++++
ld/testsuite/ld-x86-64/pr17618.d | 1 -
ld/testsuite/ld-x86-64/x86-64.exp | 6 +++++-
4 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/ld/ChangeLog b/ld/ChangeLog
index b6d378fed2..e4e6bfe5e3 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,11 @@
+2017-08-09 H.J. Lu <hongjiu.lu@intel.com>
+
+ * testsuite/config/default.exp (LD_CLASS): New. Set to "64bit"
+ for 64-bit ELF linker.
+ * testsuite/ld-x86-64/pr17618.d (#notarget): Removed.
+ * testsuite/ld-x86-64/x86-64.exp: Run pr17618 only for 64-bit
+ linker.
+
2017-08-08 H.J. Lu <hongjiu.lu@intel.com>
PR ld/21924
diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp
index f5cb188478..355d98f24a 100644
--- a/ld/testsuite/config/default.exp
+++ b/ld/testsuite/config/default.exp
@@ -251,6 +251,16 @@ if ![info exists LDFLAGS] then {
set LDFLAGS {}
}
+# Set LD_CLASS to "64bit" for 64-bit LD.
+if { ![info exists LD_CLASS] } then {
+ set readelf_output [run_host_cmd "$READELF" "-h $LD"]
+ if { [regexp {[ \t]+Class:[ \t]+ELF64} $readelf_output] } then {
+ set LD_CLASS "64bit"
+ } else {
+ set LD_CLASS "32bit"
+ }
+}
+
# Set PLT_CFLAGS to "-fplt" if target compiler supports it.
if { ![info exists PLT_CFLAGS] } then {
diff --git a/ld/testsuite/ld-x86-64/pr17618.d b/ld/testsuite/ld-x86-64/pr17618.d
index b090aa0e18..e640b4044e 100644
--- a/ld/testsuite/ld-x86-64/pr17618.d
+++ b/ld/testsuite/ld-x86-64/pr17618.d
@@ -1,5 +1,4 @@
#name: PLT PC-relative offset overflow check
#as: --64
#ld: -shared -melf_x86_64
-#notarget: x86_64-*-linux*-gnux32
#error: .*PC-relative offset overflow in PLT entry for `bar'
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index ce29cc8634..0375da6aa6 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -1572,7 +1572,11 @@ run_ld_link_tests [list \
]
# Linux only tests
-run_dump_test "pr17618"
+global LD_CLASS
+if { "$LD_CLASS" == "64bit" } then {
+ # This test needs 64-bit linker.
+ run_dump_test "pr17618"
+}
run_dump_test "pltgot-1"
run_dump_test "pltgot-2"
run_dump_test "pr20830a"
--
2.13.4