public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: Joseph Myers <joseph@codesourcery.com>
Cc: binutils@sourceware.org, libc-alpha@sourceware.org
Subject: Re: Emit a warning when -z relro is unsupported
Date: Wed, 29 Jul 2020 16:40:02 +0930	[thread overview]
Message-ID: <20200729071002.GP9601@bubble.grove.modra.org> (raw)
In-Reply-To: <20200729003850.GO9601@bubble.grove.modra.org>

[-- Attachment #1: Type: text/plain, Size: 1163 bytes --]

I believe the ia64-linux glibc problem is triggered by a fairly simple
glibc build bug.  There is a linker bug too.

I was able to reproduce the problem, with
.IA_64.unwind__libc_freeres_fn being mapped to bfd_abs_section, which
is what happens when a section is discarded by a linker script.

On looking at glibc/shlib.lds I see toward the end:

  .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
  /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_/home/local/bin/../lib/gcc/ia64-linux/9.3.1/../../../../ia64-linux/bin/ld: warning: -z relro ignored
*) }
}

Uh oh, the script will discard all orphan sections due to *(*)
appearing.  (Yes there are some odd section match patterns before
that from the warning, but the final * gets everything.)

Now .IA_64.unwind__libc_freeres_fn is not an orphan, but it is
SHF_LINK_ORDER and __libc_freeres_fn is its linked-to section, and
that one is an orphan.  ldelf_before_place_orphans handles linked-to
sections, correctly discarding .IA_64.unwind__libc_freeres_fn but
failing to set SEC_EXCLUDE which would avoid the ldwrite.c assertion.

glibc patch attached

-- 
Alan Modra
Australia Development Lab, IBM

[-- Attachment #2: 0006-Don-t-mix-linker-error-messages-into-edited-scripts.patch --]
[-- Type: text/x-diff, Size: 1110 bytes --]

From 3425515f19d47eb2e13180fe031d94a9c13ce39b Mon Sep 17 00:00:00 2001
From: Alan Modra <amodra@gmail.com>
Date: Wed, 29 Jul 2020 16:28:57 +0930
Subject: Don't mix linker error messages into edited scripts

	* Makerules (shlib.lds): Discard linker warning output.
	(format.lds): Likewise.

diff --git a/Makerules b/Makerules
index 341db86c7e..ef0fe67d9a 100644
--- a/Makerules
+++ b/Makerules
@@ -557,7 +557,7 @@ $(common-objpfx)shlib.lds: $(common-objpfx)config.make $(..)Makerules
 	$(LINK.o) -shared -Wl,-O1 \
 		  -nostdlib -nostartfiles \
 		  $(sysdep-LDFLAGS) $(rtld-LDFLAGS) $(LDFLAGS.so) \
-		  -Wl,--verbose 2>&1 | \
+		  -Wl,--verbose 2>/dev/null | \
 	  sed > $@T \
 	      -e '/^=========/,/^=========/!d;/^=========/d' \
 	      $(if $(filter yes,$(have-hash-style)), \
@@ -1073,7 +1073,7 @@ ifneq (unknown,$(output-format))
 else
 	$(LINK.o) -shared $(sysdep-LDFLAGS) $(rtld-LDFLAGS) \
 		  $(LDFLAGS.so) $(LDFLAGS-lib.so) \
-		  -x c /dev/null -o $@.so -Wl,--verbose -v 2>&1 \
+		  -x c /dev/null -o $@.so -Wl,--verbose -v 2>/dev/null \
 	| sed -n -f $< > $@.new
 	test -s $@.new
 	rm -f $@.so

       reply	other threads:[~2020-07-29  7:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200619024818.GA21885@bubble.grove.modra.org>
     [not found] ` <alpine.DEB.2.21.2007282255020.6112@digraph.polyomino.org.uk>
     [not found]   ` <20200729003850.GO9601@bubble.grove.modra.org>
2020-07-29  7:10     ` Alan Modra [this message]
2020-07-29 16:25       ` Florian Weimer
2020-07-29 22:47         ` Joseph Myers
2020-08-04 20:57         ` Carlos O'Donell
2020-08-04 23:54           ` Carlos O'Donell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200729071002.GP9601@bubble.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).