diff options
| author | Ed Maste <emaste@FreeBSD.org> | 2015-05-27 12:57:31 +0000 |
|---|---|---|
| committer | Ed Maste <emaste@FreeBSD.org> | 2015-05-27 12:57:31 +0000 |
| commit | d8a0b3e7b110453a0d5558b4c1128a071b846d3f (patch) | |
| tree | da6ab4db6267338140db87bda725eb9fa8c60b25 /elfcopy/main.c | |
| parent | d400e40862bdee2fea9afc4b27b3391807a9050c (diff) | |
Diffstat (limited to 'elfcopy/main.c')
| -rw-r--r-- | elfcopy/main.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/elfcopy/main.c b/elfcopy/main.c index a48aea589748..cbd48d3fc4b9 100644 --- a/elfcopy/main.c +++ b/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. */ |
