summaryrefslogtreecommitdiffstats
path: root/contrib/elftoolchain
diff options
context:
space:
mode:
authoremaste <emaste@FreeBSD.org>2016-02-16 14:03:25 +0000
committeremaste <emaste@FreeBSD.org>2016-02-16 14:03:25 +0000
commit284f6cde63476cc099b272baa04262937e75e289 (patch)
treeb61989449d793946735ddcc30d3edd221509607f /contrib/elftoolchain
parent05bc01be325d003f15773baf0c11c0d8aca64e0a (diff)
downloadFreeBSD-src-284f6cde63476cc099b272baa04262937e75e289.zip
FreeBSD-src-284f6cde63476cc099b272baa04262937e75e289.tar.gz
Allow elfcopy to convert between two non-ELF formats
If the output object is not an ELF file, choose an arbitrary ELF format for the intermediate file. srec, ihex and binary formats are independent of class, endianness and machine type so these choices do not affect the output. ELF Tool Chain ticket #517 Reviewed by: kai Obtained from: ELF Tool Chain r3411
Diffstat (limited to 'contrib/elftoolchain')
-rw-r--r--contrib/elftoolchain/elfcopy/main.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/contrib/elftoolchain/elfcopy/main.c b/contrib/elftoolchain/elfcopy/main.c
index b51ba4e..31d34a8 100644
--- a/contrib/elftoolchain/elfcopy/main.c
+++ b/contrib/elftoolchain/elfcopy/main.c
@@ -641,6 +641,18 @@ create_file(struct elfcopy *ecp, const char *src, const char *dst)
* ELF object before processing.
*/
if (ecp->itf != ETF_ELF) {
+ /*
+ * If the output object is not an ELF file, choose an arbitrary
+ * ELF format for the intermediate file. srec, ihex and binary
+ * formats are independent of class, endianness and machine
+ * type so these choices do not affect the output.
+ */
+ if (ecp->otf != ETF_ELF) {
+ if (ecp->oec == ELFCLASSNONE)
+ ecp->oec = ELFCLASS64;
+ if (ecp->oed == ELFDATANONE)
+ ecp->oed = ELFDATA2LSB;
+ }
create_tempfile(&elftemp, &efd);
if ((ecp->eout = elf_begin(efd, ELF_C_WRITE, NULL)) == NULL)
errx(EXIT_FAILURE, "elf_begin() failed: %s",
OpenPOWER on IntegriCloud