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]

ARM: Don't tail-pad over-aligned sections


Some recent hand-written assembler files have started to make use of
functions that are aligned to cache line boundaries.  This has
highlighted an issue with gas where the section containing the
over-aligned function is then tail-padded at the end to the level of the
over-alignment, even though the following section has a less strict
alignment.

GAS for ARM currently tail-pads sections out to the natural alignment of
the section.  If the section contains over-alignment to permit alignment
of branches, this causes the section to be padded out to that alignment
as well, so even if the code following has minimal alignment constraints
the space is still padded out with NOPs.

This patch changes that behaviour as follows:
1) non-code sections are not padded out at all - this appears to be the
normal behaviour in gas if HANDLE_ALIGN is not defined
2) Code sections are padded out to the lower of the natural alignment of
the section and 4 bytes.  This permits thumb1 sections with no alignment
limits to retain their unpadded behaviour, while maintining existing
padding behaviour for traditional thumb code that has 4-byte alignment.
 Note that the linker will pad code sections with 0 rather than NOPs, so
code that drops through from one linker section to another might
silently change behaviour after this change if it really does rely on
code padding.

The desire to try to keep thumb padding to 4-byte boundaries is due to
the worry that this change might otherwise break concatenation of code
sequences to form a larger whole.  While this is probably undefined in
practice, this change should allow for maximum backwards compatibility
while still achieving the overall desire of not overly padding objects.
It's still possible to forcibly pad out a section to a particuar
alignment by putting an explicit alignment directive at the end of the
section.

This change causes a degree of disruption in the testsuite.  I think all
the changes are benign, but one change is worthy of note.  The
armthumb-lib test for v4t no-longer has a 16-byte aligned entry point.
The reason for this is that the entry point is a veneer, not the address
of the function itself.  In the past it was just a co-incidence that
this address was also 16-byte aligned but the test seems to have been
written on the assumption that it was required.  I can think of no
reason why that should be the case (and indeed, I can think of a very
good one why it shouldn't - if multiple functions had this behaviour,
then a shared library would end up with very sparse entry veneers
wasting lots of space).  Furthermore, taking the address of a function
in a shared library isn't gauranteed to return the actual address of the
function itself, just the address of an entry point for it, which might
even be a PLT slot in another DSO or the main image itself - so there is
no way that applications can usefully rely on this aligned nature.

The other testsuite issues have mostly been fixed by skipping over the
unspecified padding elements.

Regression tested on arm-eabi and pushed to trunk.

R.


[ARM]: Don't tail-pad over-aligned functions to the alignment boundary.

2015-04/24  Richard Earnshaw  <rearnsha@arm.com>

    	gas/
    	* config/tc-arm.h (arm_min): New function.
    	(SUB_SEGMENT_ALIGN): Define.

    	gas/testsuite/
    	* gas/arm/align64.d: Delete trailing padding NOPs.

    	ld/testsuite/
    	* ld-arm/armthumb-lib.d: Regenerate expected output.
    	* ld-arm/armthumb-lib.d: Likewise.
    	* ld-arm/armthumb-lib.sym: Likewise.
    	* ld-arm/cortex-a8-fix-b-rel-arm.d: Likewise.
    	* ld-arm/cortex-a8-fix-b-rel-thumb.d: Likewise.
    	* ld-arm/cortex-a8-fix-b.d: Likewise.
    	* ld-arm/cortex-a8-fix-bcc-rel-thumb.d: Likewise.
    	* ld-arm/cortex-a8-fix-bcc.d: Likewise.
    	* ld-arm/cortex-a8-fix-bl-rel-arm.d: Likewise.
    	* ld-arm/cortex-a8-fix-bl-rel-plt.d: Likewise.
    	* ld-arm/cortex-a8-fix-bl-rel-thumb.d: Likewise.
    	* ld-arm/cortex-a8-fix-bl.d: Likewise.
    	* ld-arm/cortex-a8-fix-blx-bcond.d: Likewise.
    	* ld-arm/cortex-a8-fix-blx-rel-arm.d: Likewise.
    	* ld-arm/cortex-a8-fix-blx-rel-thumb.d: Likewise.
    	* ld-arm/cortex-a8-fix-blx.d: Likewise.
    	* ld-arm/cortex-a8-fix-hdr.d: Likewise.
    	* ld-arm/farcall-mixed-app-v5.d: Likewise.
    	* ld-arm/farcall-mixed-app.d: Likewise.
    	* ld-arm/farcall-mixed-lib-v4t.d: Likewise.
    	* ld-arm/farcall-mixed-lib.d: Likewise.
    	* ld-arm/mixed-app-v5.d: Likewise.
    	* ld-arm/mixed-app.d: Likewise.
    	* ld-arm/mixed-lib.d: Likewise.

Attachment: tailpad-arm.patch
Description: Text document


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