ports/devel/nasm/files/patch-elf64-alignment
Adam Weinberger cff9f73b44 Add a patch, taken from the nasm repo, written by emaste, that fixes
alignment on 64-bit archs.

From emaste:

Essentially what happens is that nasm creates object files that have
section contents aligned to 16 bytes, but it only specifies that the
section requires 4 byte alignment. It seems that the GNU tools (strip
at least) silently correct this to 8, which is what it should be.

This fix only affects FreeBSD -CURRENT in combination with another
(not yet committed) fix to libtool. On stable/10 and earlier GNU ld
masks the nasm bug, and without the libtool fix we don't yet try to
strip debug info from object files in -CURRENT.

PORTREVISION bump for this.

Also, while here, rename two other patches to have proper separators
(_ instead of +).

And, donate this port back to ports@. It is used by many other ports
so it deserves to be maintained by the collective.
2015-04-19 19:06:55 +00:00

54 lines
1.9 KiB
Text

From 1f0cb0f2c1ba632c0fab02424928cfb756a9160c Mon Sep 17 00:00:00 2001
From: Ed Maste <emaste@freebsd.org>
Date: Thu, 16 Apr 2015 00:59:52 +0300
Subject: [PATCH] output: elf64 -- increase .symtab and .rel* alignment to 8
Discovered while working on ELF Tool Chain elfcopy (strip),
which originally crashed on an assert while processing
a nasm-generated ELF object.
The .symtab and .rela.text sections report 4 byte alignment,
but require 8.
As an aside, see https://sourceforge.net/p/elftoolchain/tickets/485/ for a
discussion of the ELF Tool Chain issue that this bug exposed.
With my WIP elfcopy change and nasm-assembled jccolss2-64.o from libjpeg-turbo:
% strip -o /dev/null --strip-debug jccolss2-64.o
strip: section .symtab alignment 4 increased to 8
strip: section .rela.text alignment 4 increased to 8
http://bugzilla.nasm.us/show_bug.cgi?id=3392307
Signed-off-by: Ed Maste <emaste@freebsd.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
output/outelf64.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git output/outelf64.c output/outelf64.c
index 241e345..19bd845 100644
--- output/outelf64.c
+++ output/outelf64.c
@@ -1084,7 +1084,7 @@ static void elf_write(void)
/* .symtab */
elf_section_header(p - shstrtab, SHT_SYMTAB, 0, symtab, true,
- symtablen, sec_strtab, symtablocal, 4, 24);
+ symtablen, sec_strtab, symtablocal, 8, 24);
p += strlen(p) + 1;
/* .strtab */
@@ -1096,7 +1096,7 @@ static void elf_write(void)
for (i = 0; i < nsects; i++)
if (sects[i]->head) {
elf_section_header(p - shstrtab, SHT_RELA, 0, sects[i]->rel, true,
- sects[i]->rellen, sec_symtab, i + 1, 4, 24);
+ sects[i]->rellen, sec_symtab, i + 1, 8, 24);
p += strlen(p) + 1;
}
--
1.7.6.6.GIT