From 3efeb2b693efcd83c355f417452e316492426af6 Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Fri, 17 Oct 2003 15:43:13 +0000 Subject: [PATCH] Explicitly specify an alignment for abitag. Without it, gcc specifies a section alignnment of 16 bytes for amd64 and this breaks file(1). Before: ./cp: ELF 64-bit LSB executable, AMD x86-64, version 1 (FreeBSD), for \ FreeBSD 127.7.9, statically linked, stripped after: ^^^^^^^ ./ls: ELF 64-bit LSB executable, AMD x86-64, version 1 (FreeBSD), for \ FreeBSD 5.0.1, dynamically linked (uses shared libs), stripped The reason for this is that the NOTE sections are not contiguous internally. If the note section has an alignment of 16, then anything that looks for the data is supposed to round up the payload start to the next multiple of the alignment. But FreeBSD/amd64 broke because the structure is declared as a single structure, not a (header,payload) group, where the payload had an explicit alignment roundup. The alternative is to change things like file(1) to ignore the ELF payload alignment rules for the PT_NOTE section only for FreeBSD. --- lib/csu/common/crtbrand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/csu/common/crtbrand.c b/lib/csu/common/crtbrand.c index 9405f91af1b1..dde60b38bb48 100644 --- a/lib/csu/common/crtbrand.c +++ b/lib/csu/common/crtbrand.c @@ -43,7 +43,7 @@ static const struct { int32_t type; char name[sizeof ABI_VENDOR]; int32_t desc; -} abitag __attribute__ ((section (ABI_SECTION))) __unused = { +} abitag __attribute__ ((section (ABI_SECTION), aligned(4))) __unused = { sizeof ABI_VENDOR, sizeof(int32_t), ABI_NOTETYPE,