elfcopy: set ELF OS/ABI field when converting from binary

PR:		228934
Submitted by:	Tiger Gao <tig@freebsdfoundation.org>
Reviewed by:	markj, jkoshy
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D23504
This commit is contained in:
Ed Maste 2020-02-12 15:59:59 +00:00
parent 348404bce1
commit 57d7e4cc2c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=357826
5 changed files with 15 additions and 2 deletions

View File

@ -1394,6 +1394,7 @@ set_output_target(struct elfcopy *ecp, const char *target_name)
ecp->oec = elftc_bfd_target_class(tgt);
ecp->oed = elftc_bfd_target_byteorder(tgt);
ecp->oem = elftc_bfd_target_machine(tgt);
ecp->abi = elftc_bfd_target_osabi(tgt);
}
if (ecp->otf == ETF_EFI || ecp->otf == ETF_PE)
ecp->oem = elftc_bfd_target_machine(tgt);

View File

@ -23,7 +23,7 @@
.\"
.\" $Id: elftc.3 3645 2018-10-15 20:17:14Z jkoshy $
.\"
.Dd December 24, 2012
.Dd February 12, 2020
.Dt ELFTC 3
.Os
.Sh NAME
@ -57,6 +57,8 @@ Query the byte order for a binary object descriptor.
Query the object format for a binary object descriptor.
.It Fn elftc_bfd_target_machine
Query the target machine for a binary object descriptor.
.It Fn elftc_bfd_target_osabi
Query the target osabi for a binary object descriptor.
.El
.It "C++ support"
.Bl -tag -compact -width indent

View File

@ -23,7 +23,7 @@
.\"
.\" $Id: elftc_bfd_find_target.3 3752 2019-06-28 01:12:53Z emaste $
.\"
.Dd June 27, 2019
.Dd February 12, 2020
.Dt ELFTC_BFD_FIND_TARGET 3
.Os
.Sh NAME
@ -48,6 +48,8 @@
.Fn elftc_bfd_target_flavor "Elftc_Bfd_Target *target"
.Ft "unsigned int"
.Fn elftc_bfd_target_machine "Elftc_Bfd_Target *target"
.Ft "unsigned int"
.Fn elftc_bfd_target_osabi "Elftc_Bfd_Target *target"
.Sh DESCRIPTION
Function
.Fn elftc_bfd_find_target

View File

@ -71,3 +71,10 @@ elftc_bfd_target_machine(Elftc_Bfd_Target *tgt)
return (tgt->bt_machine);
}
unsigned int
elftc_bfd_target_osabi(Elftc_Bfd_Target *tgt)
{
return (tgt->bt_osabi);
}

View File

@ -72,6 +72,7 @@ Elftc_Bfd_Target_Flavor elftc_bfd_target_flavor(Elftc_Bfd_Target *_tgt);
unsigned int elftc_bfd_target_byteorder(Elftc_Bfd_Target *_tgt);
unsigned int elftc_bfd_target_class(Elftc_Bfd_Target *_tgt);
unsigned int elftc_bfd_target_machine(Elftc_Bfd_Target *_tgt);
unsigned int elftc_bfd_target_osabi(Elftc_Bfd_Target *_tgt);
int elftc_copyfile(int _srcfd, int _dstfd);
int elftc_demangle(const char *_mangledname, char *_buffer,
size_t _bufsize, unsigned int _flags);