Bug 228934 - objcopy (from elftoolchain) does not set ELF OS/ABI field for binary->ELF conversion
Summary: objcopy (from elftoolchain) does not set ELF OS/ABI field for binary->ELF con...
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Ed Maste
URL:
Keywords:
Depends on:
Blocks: 231027
  Show dependency treegraph
 
Reported: 2018-06-12 13:24 UTC by Ed Maste
Modified: 2020-02-12 16:07 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Maste freebsd_committer 2018-06-12 13:24:22 UTC
One of the steps in building the amd64 64-bit linuxulator vdso is:
> objcopy --input-target binary --output-target elf64-x86-64-freebsd -S -g --binary-architecture i386:x86-64 linux_locore.o linux_vdso.so

This should set the ELF header OS/ABI field to FreeBSD. GNU objcopy does; ELF Tool Chain objcopy/elfcopy sets it to none/SYSV. With --output-target elf64-x86-64 GNU objcopy sets it to none/SYSV.

(Using --output-target elf64-x86-64-freebsd is actually a bug in the Linuxulator Makefile: the vdso is in fact supposed to be a Linux shared object, which is a separate issue to be fixed.)
Comment 1 commit-hook freebsd_committer 2018-06-12 13:32:48 UTC
A commit references this bug:

Author: emaste
Date: Tue Jun 12 13:32:42 UTC 2018
New revision: 334998
URL: https://svnweb.freebsd.org/changeset/base/334998

Log:
  linux64: use linux output target for linux_vdso.so

  linux_vdso.so provides the vdso for the linuxulator's amd64 target and
  is mapped into a Linux binary's address space.  Thus it should be a
  Linux-style .so, which has the ELF OS/ABI unset.

  It turns out that ELF Tool Chain elfcopy/objcopy also has a bug where
  the OS/ABI field is unset, regardless of the specified --output-target,
  so this change is a no-op with the default in-tree toolchain.  This is a
  real fix when using external binutils, and the ELF Tool Chain bug will
  be fixed in the future.

  PR:		228934
  Sponsored by:	Turing Robotic Industries

Changes:
  head/sys/modules/linux64/Makefile
Comment 2 commit-hook freebsd_committer 2020-02-12 16:01:02 UTC
A commit references this bug:

Author: emaste
Date: Wed Feb 12 16:00:00 UTC 2020
New revision: 357826
URL: https://svnweb.freebsd.org/changeset/base/357826

Log:
  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

Changes:
  head/contrib/elftoolchain/elfcopy/main.c
  head/contrib/elftoolchain/libelftc/elftc.3
  head/contrib/elftoolchain/libelftc/elftc_bfd_find_target.3
  head/contrib/elftoolchain/libelftc/elftc_bfdtarget.c
  head/contrib/elftoolchain/libelftc/libelftc.h
Comment 3 Ed Maste freebsd_committer 2020-02-12 16:07:00 UTC
Committed to FreeBSD, will upstream and MFC soon