This is the mail archive of the 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] [LD] Add ALIGN_WITH_INPUT output section attribute

Let me explain a bit more why this feature is important for us. We support the open source real-time operating system RTEMS and we use the GNU tool chain (GCC and Binutils). We use it on a couple of architectures and various chips. It
ranges from small-scale platforms (KiB of code and data space) to multi-core
high-performance embedded systems with GiB of RAM available.  The ARM and
PowerPC platforms for example offer chips in the whole range.  So it is
tempting to use one general linker command file to cover all systems of an

We want to use the GNU tool chain alone.  Some software or hardware vendors
ship fancy (closed source) development environments that generate perfect
linker command files automatically for their systems with nice wizards. We do
not want this.  We want simple self-contained text files that you can open,
read and edit in 30 years from now [1].

Why not use the default linker command file? On the small-scale systems there is no room for an ELF-loader due to resource constraints. These systems tend to have a very scattered memory map. You have internal and off-chip flashes,
SRAMs, MRAMS, SDRAMS, etc.  You have internal SRAMs that are located in
different peripherals that can be also use as a general-purpose RAM. The GNU
ld offers the VMA and LMA regions to deal with this issue.  For each output
section you can say the VMA addresses go into this region and for the LMA use that region. To make this flexible I added the REGION_ALIAS feature to GNU ld
in 2009 (

Various standards and tools expect to see certain output sections in the
executable ELF file. So the approach to merge output sections together to deal
with the change to fix PR15222 did not work
(  This leaves a
command line option or an addition to the linker script language. The addition to the linker script language offers more flexibility. I hope that this change
is acceptable in principle.

[1] Imagine software for long lasting goods like container ship Diesel engines
or large power plants.

On 28/06/13 09:23, Sebastian Huber wrote:

what is the background of this patch?

Before 2.23.2 I did this:

1. Get the default linker script (ld --verbose).

2. For each output section select a VMA and LMA region.

3. Sort the output sections according to LMA region and preserve order of default linker script in each LMA region equivalence class.

4. Add begin, end and size symbols for each VMA and LMA region pair. Use memcpy() in the application start code to initialize the VMA regions.

5. Add custom sections.

With the change in 2.23.2 step 4 is broken. I had to merge all output sections of a VMA and LMA region pair into one. This breaks for example the dynamic linking and debugging in C++. I had to introduce special cases for small-data areas and ARM exception tables. In order to overcome these problems I propose the ALIGN_WITH_INPUT attribute to restore the behaviour prior to 2.23.2.

Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  :
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

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