[patch] coff: fix alignment issues when building on ARM

Michael Tautschnig tautschn@model.in.tum.de
Mon Dec 4 21:22:00 GMT 2006


Hi!

Even though this patch aims at the 2.16.1 release of binutils it should apply
(and work!) to current HEAD as well as things have not changed in that area.
However, I understand that coff targets are of less interest...

The issue is the alignment/padding added on ARM, such that the effective size
(as reported by sizeof) is 2 bytes larger than the #define'd sizes. This causes
invalid coff files to be generated by gas. The attached patch fixed all problems
while building gcc packages for the h8300-hitachi-coff target.

Best,
Michael




-------------- next part --------------
#! /bin/sh /usr/share/dpatch/dpatch-run
## 130_coff_arm.dpatch 
##
## DP: Description: Fix alignment error on ARM
## DP: Author: Michael Tautschnig <tautschn@model.in.tum.de>
## DP: Upstream status: N/A

if [ $# -ne 1 ]; then
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
    exit 1
fi

[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
patch_opts="${patch_opts:--f --no-backup-if-mismatch}"

case "$1" in
       -patch) patch $patch_opts -p1 < $0;;
       -unpatch) patch $patch_opts -p1 -R < $0;;
        *)
                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
                exit 1;;
esac

exit 0

@DPATCH@
--- binutils-h8300-hms-2.16.1.orig/include/coff/external.h
+++ binutils-h8300-hms-2.16.1/include/coff/external.h
@@ -50,7 +50,7 @@
     char entry[4];	/* entry pt.				*/
     char text_start[4];	/* base of text used for this file 	*/
     char data_start[4];	/* base of data used for this file 	*/
-  }
+  } __attribute__((packed))
 AOUTHDR;
 
 #define AOUTHDRSZ 28
@@ -150,7 +150,7 @@
   char e_type[2];
   char e_sclass[1];
   char e_numaux[1];
-};
+} __attribute__((packed));
 
 #define	SYMENT	struct external_syment
 #define	SYMESZ	18	
@@ -242,7 +242,7 @@
     char x_tvlen[2];	/* length of .tv */
     char x_tvran[2][2];	/* tv range */
   } x_tv;		/* info about .tv section (in auxent of symbol .tv)) */
-};
+} __attribute__((packed));
 
 #define	AUXENT	union external_auxent
 #define	AUXESZ	18
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20061204/e71f08ce/attachment.sig>


More information about the Binutils mailing list