ARM section alignment

Jonathan S. Shapiro shap@eros-os.com
Tue Jun 17 03:15:00 GMT 2008


On Mon, 2008-06-16 at 09:15 +0100, Nick Clifton wrote:
> Hi Jonathan,
> 
> >> -z max-page-size should work.
> > 
> > Umm. I wasn't clear. I was looking for a way to override it from a
> > target-specific header file. My feeling is that the __QNXTARGET__ trick
> > is the start of an undesirable trend...
> 
> If you are using a target specific header file, why can't you use a 
> target specific makefile, or makefile fragment ?
> 
> Essentially this is a link-time parameter that you are trying to change. 

This does not seem obvious. If this is indeed a link-time parameter,
then it should not be expressed in a #define at all. It should be part
of the link-time emulation template and/or link time command line
option.

My concern is that it actually *isn't* a link time parameter, because
there are various tools that use libbfd to perform various sorts of
object to object rewrites, and these tools will tend (perhaps
mistakenly) to rely on the parameterizations that are compiled into
libbfd.

What I think I am saying here is the following:

1. If, in fact, this is a link-time parameter, then it has no business
   being encoded in a #define, except perhaps as a default value. This
   seems to be what is actually going on for most architectures.

2. Given the presence of the __QNXTARGET__ macro, it is obvious that the
   default value for ARM is not determined by architecture, but rather
   by target triple. If this continues to be true, then it is a value
   that should be overridable by target-triple-specific configuration
   files during the build.

3. In this case, it seems evident that what the __QNXTARGET__ macro
   is really doing is correcting a default that was established for
   legacy reasons but is no longer appropriate.

I think that at some inchoate level I am a bit disturbed that libbfd.a
has compiled-in non-architectural target triple assumptions at all; it
seems like it ought to be possible for libbfd to simultaneously support
a wide range of targets for a given architecture. I understand that this
isn't how things are, and I'm not trying to propose a grand fix, and I
acknowledge that this is uncomfortable feeling of mine is probably a
distraction from the issue at hand.

>   Altering this from a C/C++ header file is the wrong way to go about 
> it.  If you have target specific memory layout requirements then you 
> should be using a target specific linker map.

In abstract I agree, but there are two problems here. (1) It isn't just
a linker issue for reasons that I mentioned above, and (2) in this case
we DID build a target specific linker map, and the MAXPAGESIZE value
that is compiled into the arm-elf libbfd support had the effect of
establishing an excessive phdr alignment restriction in *spite* of our
custom linker script.

This is why I raised the possibility of the fix that I suggested in
earlier email:

  1. Change MAXPAGESIZE to 0x1000, matching the majority of current
     usage and permitting linker scripts to operate in the way that
     you propose (which doesn't work now).

  2. Having done so, kill the __QNXTARGET__macro off -- at least here.

  3. Let users who require 0x8000 alignment do it with a linker script,
     which seems like it might have been the right approach all along.


I feel like I'm dragging all of this out, but that certainly isn't my
intention. We can and will patch this locally if we need to. It's just
that looking at the current behavior I think the "fix" to this should
probably be applied upstream.

shap



More information about the Binutils mailing list