summaryrefslogtreecommitdiffstats
path: root/contrib/elftoolchain/elfcopy/main.c
diff options
context:
space:
mode:
authoremaste <emaste@FreeBSD.org>2015-05-27 14:28:19 +0000
committeremaste <emaste@FreeBSD.org>2015-05-27 14:28:19 +0000
commitaa01a21e0c7d20fb276cc0628a159a595e0e617e (patch)
tree74d3c6f019cc59be7b175c8db630ad55260c4062 /contrib/elftoolchain/elfcopy/main.c
parentabf78a3a279a4db8cb4d6cc74dae9ae4c35003e4 (diff)
downloadFreeBSD-src-aa01a21e0c7d20fb276cc0628a159a595e0e617e.zip
FreeBSD-src-aa01a21e0c7d20fb276cc0628a159a595e0e617e.tar.gz
Update to ELF Tool Chain r3223
Highlights (upstream revisions): - Fix SHT_GROUP handling in elfcopy/strip (3206 3220 3221) - Misc elfcopy / strip bug fixes (3215 3216 3217) - Many C++ demangler improvements (3199 3200 3201 3202 3203 3204 3205 3208 3210 3211 3212) - Improve GNU binutils compatibility in elfcopy / strip (3213 3214) - Add -g option to readelf(1): dump contents of section groups (3219) - Add EM_IAMCU 32-bit Intel MCU (3198) Also add a compat #define for building with older FreeBSD ELF headers. The GRP_COMDAT flag was added to elf_common.h in r283110, but it's not available during the bootstrap build. It is also convenient to be able to build on older hosts. Thanks to antoine@ for tracking down issues through multiple exp-runs and to kaiw@ for fixing. PR: 198611 (exp-run), 200350 Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'contrib/elftoolchain/elfcopy/main.c')
-rw-r--r--contrib/elftoolchain/elfcopy/main.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/contrib/elftoolchain/elfcopy/main.c b/contrib/elftoolchain/elfcopy/main.c
index a48aea5..cbd48d3 100644
--- a/contrib/elftoolchain/elfcopy/main.c
+++ b/contrib/elftoolchain/elfcopy/main.c
@@ -39,7 +39,7 @@
#include "elfcopy.h"
-ELFTC_VCSID("$Id: main.c 3174 2015-03-27 17:13:41Z emaste $");
+ELFTC_VCSID("$Id: main.c 3216 2015-05-23 21:16:36Z kaiwang27 $");
enum options
{
@@ -404,8 +404,19 @@ create_elf(struct elfcopy *ecp)
* Insert SHDR table into the internal section list as a "pseudo"
* section, so later it will get sorted and resynced just as "normal"
* sections.
+ *
+ * Under FreeBSD, Binutils objcopy always put the section header
+ * at the end of all the sections. We want to do the same here.
+ *
+ * However, note that the behaviour is still different with Binutils:
+ * elfcopy checks the FreeBSD OSABI tag to tell whether it needs to
+ * move the section headers, while Binutils is probably configured
+ * this way when it's compiled on FreeBSD.
*/
- shtab = insert_shtab(ecp, 0);
+ if (oeh.e_ident[EI_OSABI] == ELFOSABI_FREEBSD)
+ shtab = insert_shtab(ecp, 1);
+ else
+ shtab = insert_shtab(ecp, 0);
/*
* Resync section offsets in the output object. This is needed
@@ -485,6 +496,11 @@ free_elf(struct elfcopy *ecp)
free(sec);
}
}
+
+ if (ecp->secndx != NULL) {
+ free(ecp->secndx);
+ ecp->secndx = NULL;
+ }
}
/* Create a temporary file. */
OpenPOWER on IntegriCloud