public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: "H. J. Lu" <hjl@lucon.org>, Paul Brook <paul@codesourcery.com>,
	        binutils@sourceware.org,
	Paul Koning <pkoning@equallogic.com>,
	        vgoyal@redhat.com, drow@false.org,
	binutils@sources.redhat.com
Subject: Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
Date: Wed, 11 Oct 2006 14:19:00 -0000	[thread overview]
Message-ID: <20061011071125.GL4556@sunsite.mff.cuni.cz> (raw)
In-Reply-To: <20061011035305.GA19554@bubble.grove.modra.org>

On Wed, Oct 11, 2006 at 01:23:05PM +0930, Alan Modra wrote:
> On Wed, Oct 11, 2006 at 01:19:22AM +0200, Jakub Jelinek wrote:
> > Either we could add here REMOVE_EMPTY flag, or, perhaps better, not consider
> > at least symbol = absolute value assignments as section relative,
> 
> Sections containing symbols really do need to stay, for --emit-relocs
> and dynamic relocs.  Or at least, we need to do something to make them
> work properly.

Dynamic relocs aren't an issue here, in both cases we are talking about
executables and the the __{{pre,}init,fini}_array_{start,end} symbols
are PROVIDE_HIDDEN and __SDA_BASE__ likely should be PROVIDE_HIDDEN too
(and, furthermore for __SDA_BASE__ using section relative symbol is wrong,
as it is assigned a constant value, unrelated to the current section
(and in any case tweaked by the ppc backend; if there is non-empty
.sdata, __SDA_BASE__ is even ABS, only when it is empty it is section
relative ATM)).  For --emit-relocs and the init/fini array symbols
we again don't care what exact values they have, as long as a post-linking
tool doesn't want to add things into one of the previously empty
.init_array etc. sections.  But, such tool either would need to be
aware what these symbols mean and set them properly after inserting
stuff there, the *_array_start one to the beginning of the section and
*_array_end to the end of the section, or it would do the wrong thing
(kept either both symbols at the beginning, or end of the section it
grew, in any case for the _start code this would mean there is no such
section).

Against emitting empty sections speaks both that it is a wasted space
in section header table/.shstrtab, but more importantly that empty
sections are an endless source of bugs (as shown yesterday e.g.
on x86-64) in almost every tool that needs to deal with them.
This is not the first time ld didn't get sh_offsets for empty sections
right, I remember fighting with that several times in prelink, strip/objcopy
was messing them up in the past too and prelink had bugs in handling them
too.

	Jakub

WARNING: multiple messages have this Message-ID
From: Jakub Jelinek <jakub@redhat.com>
To: "H. J. Lu" <hjl@lucon.org>, Paul Brook <paul@codesourcery.com>,
	        binutils@sourceware.org,
	Paul Koning <pkoning@equallogic.com>,
	        vgoyal@redhat.com, drow@false.org,
	binutils@sources.redhat.com
Subject: Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
Date: Wed, 11 Oct 2006 14:45:00 -0000	[thread overview]
Message-ID: <20061011071125.GL4556@sunsite.mff.cuni.cz> (raw)
Message-ID: <20061011144500.vYIlfdnWxMSZrBcieuiiHqXYXAl8acNXo5Kq0Fjhj_Y@z> (raw)
In-Reply-To: <20061011035305.GA19554@bubble.grove.modra.org>

On Wed, Oct 11, 2006 at 01:23:05PM +0930, Alan Modra wrote:
> On Wed, Oct 11, 2006 at 01:19:22AM +0200, Jakub Jelinek wrote:
> > Either we could add here REMOVE_EMPTY flag, or, perhaps better, not consider
> > at least symbol = absolute value assignments as section relative,
> 
> Sections containing symbols really do need to stay, for --emit-relocs
> and dynamic relocs.  Or at least, we need to do something to make them
> work properly.

Dynamic relocs aren't an issue here, in both cases we are talking about
executables and the the __{{pre,}init,fini}_array_{start,end} symbols
are PROVIDE_HIDDEN and __SDA_BASE__ likely should be PROVIDE_HIDDEN too
(and, furthermore for __SDA_BASE__ using section relative symbol is wrong,
as it is assigned a constant value, unrelated to the current section
(and in any case tweaked by the ppc backend; if there is non-empty
.sdata, __SDA_BASE__ is even ABS, only when it is empty it is section
relative ATM)).  For --emit-relocs and the init/fini array symbols
we again don't care what exact values they have, as long as a post-linking
tool doesn't want to add things into one of the previously empty
.init_array etc. sections.  But, such tool either would need to be
aware what these symbols mean and set them properly after inserting
stuff there, the *_array_start one to the beginning of the section and
*_array_end to the end of the section, or it would do the wrong thing
(kept either both symbols at the beginning, or end of the section it
grew, in any case for the _start code this would mean there is no such
section).

Against emitting empty sections speaks both that it is a wasted space
in section header table/.shstrtab, but more importantly that empty
sections are an endless source of bugs (as shown yesterday e.g.
on x86-64) in almost every tool that needs to deal with them.
This is not the first time ld didn't get sh_offsets for empty sections
right, I remember fighting with that several times in prelink, strip/objcopy
was messing them up in the past too and prelink had bugs in handling them
too.

	Jakub

  parent reply	other threads:[~2006-10-11  7:12 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-26 14:33 Vivek Goyal
2006-09-26 14:49 ` H. J. Lu
2006-09-26 14:52   ` Vivek Goyal
2006-09-26 15:13     ` H. J. Lu
2006-09-26 15:41       ` Daniel Jacobowitz
2006-09-26 15:54         ` Vivek Goyal
2006-09-26 16:21           ` H. J. Lu
2006-09-26 16:30             ` Vivek Goyal
2006-09-26 16:44               ` H. J. Lu
2006-09-26 16:45                 ` Vivek Goyal
2006-09-26 17:01                 ` Daniel Jacobowitz
2006-09-26 23:50                   ` Alan Modra
2006-09-27  1:51                     ` Daniel Jacobowitz
2006-09-27  3:09                       ` Daniel Jacobowitz
2006-09-26 17:48                 ` Paul Koning
2006-09-26 23:53                   ` Alan Modra
2006-09-28 17:01                     ` Paul Brook
2006-09-28 17:05                       ` Paul Brook
2006-09-28 18:37                       ` H. J. Lu
2006-09-28 18:53                         ` H. J. Lu
2006-10-10 16:41                         ` Jakub Jelinek
2006-10-10 16:51                           ` Jakub Jelinek
2006-10-11  3:52                           ` Jakub Jelinek
2006-10-11  7:12                             ` Jakub Jelinek
2006-10-11  8:04                             ` Alan Modra
2006-10-11 14:08                               ` Alan Modra
2006-10-11 14:19                               ` Jakub Jelinek [this message]
2006-10-11 14:45                                 ` Jakub Jelinek
2006-10-12 10:18                                 ` Alan Modra
2006-10-12 14:37                                   ` Alan Modra
2006-10-13 10:58                                   ` Jakub Jelinek
2006-10-13 11:10                                     ` Alan Modra
2006-10-13 11:26                                       ` Alan Modra
2006-10-17 16:02                                   ` Dynamic section symbols, ignored output sections Alan Modra
2006-10-19 14:55                                     ` ligang
2006-10-22  0:25                                     ` Jakub Jelinek
2006-10-23 14:13                                       ` Alan Modra
2006-09-29  6:42                       ` Linker Bug or Design Intent (Absolute symbols in zero sized sections) Alan Modra
2006-09-29  8:06                         ` Alan Modra
2006-09-26 16:14         ` H. J. Lu
2006-09-26 16:40           ` Vivek Goyal
2006-09-26 17:57           ` Vivek Goyal
2006-09-26 20:23             ` H. J. Lu

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=20061011071125.GL4556@sunsite.mff.cuni.cz \
    --to=jakub@redhat.com \
    --cc=binutils@sources.redhat.com \
    --cc=binutils@sourceware.org \
    --cc=drow@false.org \
    --cc=hjl@lucon.org \
    --cc=paul@codesourcery.com \
    --cc=pkoning@equallogic.com \
    --cc=vgoyal@redhat.com \
    /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).