This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Trouble eliminating padding or alignments
- From: Alex Buell <alex dot buell at munted dot org dot uk>
- To: binutils at sourceware dot org
- Date: Thu, 15 Jul 2010 15:48:28 +0100
- Subject: Trouble eliminating padding or alignments
- Reply-to: alex dot buell at munted dot org dot uk
Hi!
I'm currently working on a small project that involves building a flat
binary image as a 512 byte bootloader under Linux and tested on a
virtual machine.
The bootloader consists of an asssembly file (boot.asm) compiled by NASM
into an ELF32 object. The linking process also pulls in routines from a
library containing NASM ELF32 object files.
Previously, with all routines in one assembly file, it always generates
a binary less than 448 bytes.
Unfortunately when I needed to share some common routines with another
NASM assembly routine, I put these into its own common library archives,
used AR with 'rcs' options, but the linker now generates a flat binary
larger than it needs to be (568 bytes instead of being less than 448
bytes). And yes, I'm using --oformat binary.
On investigating with hexdump, I realised that there were extra bytes
inserted into the object files and the library archive, perhaps because
it thinks it needs to be aligned or padded, something like that.
I tried using --as-needed and -s options with the linker but it seems to
make no difference.
Is there anything I can do to eliminate these additional alignment or
padding bytes? Any help given would be much appreciated.
--
http://www.munted.org.uk
One very high maintenance cat living here.