This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR ld/16322: ld fails to generate GNU_RELRO segment


On Thu, Jan 9, 2014 at 8:41 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Thu, Jan 9, 2014 at 8:05 AM, Hans-Peter Nilsson
> <hans-peter.nilsson@axis.com> wrote:
>>> From: "H.J. Lu" <hjl.tools@gmail.com>
>>> Date: Wed, 8 Jan 2014 15:01:49 +0100
>>> >> 2013-12-12  H.J. Lu  <hongjiu.lu@intel.com>
>>> >>
>>> >>         PR ld/14207
>>> >>         PR ld/16322
>>> >>         PR binutils/16323
>>> >>         * elf.c (_bfd_elf_map_sections_to_segments): Don't check section
>>> >>         size for PT_GNU_RELRO segment.
>>> >>         (assign_file_positions_for_load_sections): If PT_LOAD segment
>>> >>         doesn't fit PT_GNU_RELRO segment, adjust its p_filesz and p_mems
>>> > Are there any objections to this patch?
>>
>> Did you get explicit approval for this patch?
>>
>>> I checked it in.  Please let me know if there are any problems.
>>
>> It fails for cris-axis-linux-gnu: no GNU_RELRO segment.
>>
>> Should I worry or is this going to be covered by follow-up
>> changes?  I see there's an ongoing conversation.
>>
>
> It fails since cris doesn't define COMMONPAGESIZE
> so that -z relro is ignored.  You can add relro support
> to cris or I can skip this test for cris.
>

I checked in this patch to check if GNU_RELRO segment
is generated.  It fails for cris-linux:

FAIL: strip -z relro (relro1)
FAIL: strip -z relro -shared (relro1)
FAIL: objcopy -z relro (relro1)
FAIL: objcopy -z relro -shared (relro1)
FAIL: objcopy -z relro (tdata1)
FAIL: objcopy -shared -z relro (tdata1)
FAIL: objcopy -z relro (tdata2)
FAIL: objcopy -shared -z relro (tdata2)
FAIL: objcopy -z relro (tdata3)
FAIL: objcopy -shared -z relro (tdata3)
FAIL: objcopy -shared -z relro (tbss1)
FAIL: objcopy -shared -z relro (tbss2)
FAIL: objcopy -shared -z relro (tbss3)

since cris-linux doesn't support relro.  We can either
ignore them for cris and add relro support to cris.

-- 
H.J.
---
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index df2e1b8..da8ce89 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2014-01-09  H.J. Lu  <hongjiu.lu@intel.com>
+
+ * ld-elf/binutils.exp (binutils_test): Check if GNU_RELRO segment
+ is generated.
+
 2014-01-09  Vidya Praveen  <vidyapraveen@arm.com>

  * lib/ld-lib.exp (check_lto_shared_available): New check.
diff --git a/ld/testsuite/ld-elf/binutils.exp b/ld/testsuite/ld-elf/binutils.exp
index 0101512..b170791 100644
--- a/ld/testsuite/ld-elf/binutils.exp
+++ b/ld/testsuite/ld-elf/binutils.exp
@@ -1,5 +1,5 @@
 # Expect script for binutils tests
-#   Copyright 2006, 2007, 2008, 2009, 2010, 2012 Free Software Foundation, Inc.
+# Copyright 2006-2013 Free Software Foundation, Inc.
 #
 # This file is part of the GNU Binutils.
 #
@@ -79,6 +79,30 @@ proc binutils_test { prog_name ld_options test
{test_name ""}} {
  return
     }

+    if [string match "*-z relro*" $ld_options] {
+ # Check if GNU_RELRO segment is generated.
+ set got [remote_exec host "grep GNU_RELRO tmpdir/$test.exp"]
+ if { ![string match "*GNU_RELRO*" $got] } then {
+    set got [remote_exec host "cat tmpdir/$test.exp"]
+    if { [string match "*.data.rel.ro*" $got]
+ || [string match "*.dynamic*" $got]
+ || [string match "*.got*" $got]
+ || [string match "*.eh_frame*" $got]
+ || [string match "*.gcc_except_table*" $got]
+ || [string match "*.exception_ranges*" $got]
+ || [string match "*.ctors*" $got]
+ || [string match "*.dtors*" $got]
+ || [string match "*.tdata*" $got]
+ || [string match "*.preinit_array*" $got]
+ || [string match "*.init_array*" $got]
+ || [string match "*.fini_array*" $got] } then {
+ # Fail if GNU_RELRO segment isn't generated, but should.
+ fail "$test_name"
+ return
+    }
+ }
+    }
+
     send_log "$prog tmpdir/$test\n"
     set got [remote_exec host "$prog tmpdir/$test"]
     if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]