Bug 10074 - objdump doesn't work on EFI
Summary: objdump doesn't work on EFI
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.20
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-15 23:04 UTC by H.J. Lu
Modified: 2009-04-17 13:50 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
A testcase (5.52 KB, application/octet-stream)
2009-04-15 23:05 UTC, H.J. Lu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2009-04-15 23:04:50 UTC
This patch:

http://sourceware.org/ml/binutils/2008-02/msg00051.html

breaks EFI. I got

[hjl@gnu-6 HelloWorldUefiGcc4.4]$ /usr/bin/objdump -p HelloWorld.efi
/usr/bin/objdump: HelloWorld.efi: File format not recognized
[hjl@gnu-6 HelloWorldUefiGcc4.4]$
Comment 1 H.J. Lu 2009-04-15 23:05:29 UTC
Created attachment 3886 [details]
A testcase
Comment 2 H.J. Lu 2009-04-15 23:07:40 UTC
he more I look at, the more I don't like the current solution.
If I understand it correctly, we added 2 EFI targets for
each arch just so that we can do

# objcopy  -O efi-XXX-x86_64 HelloWorld.elf HelloWorld.efi

The only difference between 3 EFI targets is different
IMAGE_SUBSYSTEM_EFI_XXX. Why not just have one EFI
target, efi-x8_64, defaulting to IMAGE_SUBSYSTEM_EFI_APPLICATION??
We can add a switch to objcopy with

--efi=app|bsdrv|rtdrv

We can provide backward compatibility for efi-XXX-x86_64.
Comment 3 cvs-commit@gcc.gnu.org 2009-04-17 13:46:47 UTC
Subject: Bug 10074

CVSROOT:	/cvs/src
Module name:	src
Changes by:	hjl@sourceware.org	2009-04-17 13:46:18

Modified files:
	bfd            : ChangeLog Makefile.am Makefile.in coffcode.h 
	                 config.bfd configure configure.in libcoff.h 
	                 libpei.h peXXigen.c peicode.h targets.c 
	binutils       : ChangeLog NEWS objcopy.c 
	binutils/doc   : binutils.texi 
Added files:
	bfd            : pei-ia64.c 
Removed files:
	bfd            : efi-app-ia32.c efi-app-ia64.c efi-app-x86_64.c 
	                 efi-bsdrv-ia32.c efi-bsdrv-ia64.c 
	                 efi-bsdrv-x86_64.c efi-rtdrv-ia32.c 
	                 efi-rtdrv-ia64.c efi-rtdrv-x86_64.c 

Log message:
	bfd/
	
	2009-04-17  H.J. Lu  <hongjiu.lu@intel.com>
	
	PR binutils/10074
	* coffcode.h (bfd_pei_p): New.
	
	* config.bfd: Remove bfd_efi_bsdrv_ia32_vec,
	bfd_efi_rtdrv_ia32_vec, bfd_efi_bsdrv_x86_64_vec,
	bfd_efi_rtdrv_x86_64_vec, bfd_efi_bsdrv_ia64_vec and
	bfd_efi_rtdrv_ia64_vec.  Replace bfd_efi_app_ia32_vec,
	bfd_efi_app_x86_64_vec and bfd_efi_app_ia64_vec with
	i386pei_vec, x86_64pei_vec and bfd_pei_ia64_vec, respectively.
	
	* configure.in: Remove bfd_efi_bsdrv_ia32_vec,
	bfd_efi_rtdrv_ia32_vec, bfd_efi_bsdrv_x86_64_vec,
	bfd_efi_rtdrv_x86_64_vec,
	bfd_efi_bsdrv_ia64_vec and bfd_efi_rtdrv_ia64_vec.  Replace
	bfd_efi_ia64_vec with bfd_pei_ia64_vec.
	* targets.c: Likewise.
	
	* configure: Regenerated.
	* libcoff.h: Likewise.
	* Makefile.in: Likewise.
	
	* efi-app-ia32.c: Removed.
	* efi-app-x86_64.c: Likewise.
	* efi-bsdrv-ia32.c: Likewise.
	* efi-bsdrv-ia64.c: Likewise.
	* efi-bsdrv-x86_64.c: Likewise.
	* efi-rtdrv-ia32.c: Likewise.
	* efi-rtdrv-ia64.c: Likewise.
	* efi-rtdrv-x86_64.c: Likewise.
	* efi-rtdrv-ia32.c: Likewise.
	
	* efi-app-ia64.c: Moved to ...
	* pei-ia64.c: This.
	(TARGET_SYM): Set to bfd_pei_ia64_vec.
	(TARGET_NAME): Set to pei-ia64.
	
	* libpei.h (bfd_target_pei_p): Removed.
	(bfd_target_pei_arch): Likewise.
	(bfd_target_efi_app_p): Likewise.
	(bfd_target_efi_app_arch): Likewise.
	(bfd_target_efi_bsdrv_p): Likewise.
	(bfd_target_efi_bsdrv_arch): Likewise.
	(bfd_target_efi_rtdrv_p): Likewise.
	(bfd_target_efi_rtdrv_arch): Likewise.
	(bfd_pe_executable_p): Likewise.
	
	* Makefile.am (BFD32_BACKENDS): Remove efi-app-ia32.lo,
	efi-bsdrv-ia32.lo and efi-rtdrv-ia32.lo.
	(BFD32_BACKENDS_CFILES): Remove efi-app-ia32.c, efi-bsdrv-ia32.c
	and efi-rtdrv-ia32.c.
	(BFD64_BACKENDS): Remove efi-app-ia64.lo, efi-bsdrv-ia64.lo,
	efi-rtdrv-ia64.lo, efi-app-x86_64.lo, efi-bsdrv-x86_64.lo and
	efi-rtdrv-x86_64.lo. Add pei-ia64.lo.
	(BFD64_BACKENDS_CFILES): Remove efi-app-ia64.c, efi-bsdrv-ia64.c,
	efi-rtdrv-ia64.c, efi-app-x86_64.c, efi-bsdrv-x86_64.c and
	efi-rtdrv-x86_64.c. Add pei-ia64.c.
	(efi-app-ia64.lo): Removed.
	(efi-bsdrv-ia32.lo): Likewise.
	(efi-rtdrv-ia32.lo): Likewise.
	(efi-app-ia64.lo): Likewise.
	(efi-bsdrv-ia64.lo): Likewise.
	(efi-rtdrv-ia64.lo): Likewise.
	(efi-app-x86_64.lo): Likewise.
	(efi-bsdrv-x86_64.lo): Likewise.
	(efi-rtdrv-x86_64.lo): Likewise.
	(pei-ia64.lo): New.
	
	* peicode.h (coff_swap_scnhdr_in): Replace bfd_pe_executable_p
	with bfd_pei_p.
	(arch_type): Removed.
	(pe_arch): Likewise.
	(pe_bfd_object_p): Just return coff_object_p.
	
	* peXXigen.c (_bfd_XXi_swap_scnhdr_out): Replace
	bfd_pe_executable_p with bfd_pei_p.
	
	binutils/
	
	2009-04-17  H.J. Lu  <hongjiu.lu@intel.com>
	
	PR binutils/10074
	* objcopy.c: Include coff/i386.h and coff/pe.h.
	(pe_file_alignment): New.
	(pe_heap_commit): Likewise.
	(pe_heap_reserve): Likewise.
	(pe_image_base): Likewise.
	(pe_section_alignment): Likewise.
	(pe_stack_commit): Likewise.
	(pe_stack_reserve): Likewise.
	(pe_subsystem): Likewise.
	(pe_major_subsystem_version): Likewise.
	(pe_minor_subsystem_version): Likewise.
	(set_pe_subsystem): Likewise.
	(convert_efi_target): Likewise.
	(command_line_switch): Add OPTION_FILE_ALIGNMENT,
	OPTION_HEAP, OPTION_IMAGE_BASE, OPTION_SECTION_ALIGNMENT,
	OPTION_STACK and OPTION_SUBSYSTEM.
	(copy_options): Likewise.
	(copy_usage): Add --file-alignment, --heap, --image-base,
	--section-alignment, --stack and --subsystem.
	(copy_object): Set up PE parameters.
	(copy_main): Process Add OPTION_FILE_ALIGNMENT,
	OPTION_HEAP, OPTION_IMAGE_BASE, OPTION_SECTION_ALIGNMENT,
	OPTION_STACK and OPTION_SUBSYSTEM.   Convert EFI target to
	PEI target.
	
	* NEWS: Mention --file-alignment, --heap, --image-base,
	--section-alignment, --stack and --subsystem command line
	options for objcopy.
	
	* doc/binutils.texi: Document --file-alignment, --heap,
	--image-base, --section-alignment, --stack and --subsystem
	command line options for objcopy.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/pei-ia64.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.4560&r2=1.4561
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/Makefile.am.diff?cvsroot=src&r1=1.224&r2=1.225
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/Makefile.in.diff?cvsroot=src&r1=1.247&r2=1.248
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/coffcode.h.diff?cvsroot=src&r1=1.153&r2=1.154
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/config.bfd.diff?cvsroot=src&r1=1.247&r2=1.248
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/configure.diff?cvsroot=src&r1=1.300&r2=1.301
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/configure.in.diff?cvsroot=src&r1=1.259&r2=1.260
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/libcoff.h.diff?cvsroot=src&r1=1.53&r2=1.54
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/libpei.h.diff?cvsroot=src&r1=1.22&r2=1.23
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/peXXigen.c.diff?cvsroot=src&r1=1.49&r2=1.50
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/peicode.h.diff?cvsroot=src&r1=1.56&r2=1.57
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/targets.c.diff?cvsroot=src&r1=1.169&r2=1.170
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/efi-app-ia32.c.diff?cvsroot=src&r1=1.11&r2=NONE
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/efi-app-ia64.c.diff?cvsroot=src&r1=1.9&r2=NONE
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/efi-app-x86_64.c.diff?cvsroot=src&r1=1.4&r2=NONE
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/efi-bsdrv-ia32.c.diff?cvsroot=src&r1=1.2&r2=NONE
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/efi-bsdrv-ia64.c.diff?cvsroot=src&r1=1.2&r2=NONE
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/efi-bsdrv-x86_64.c.diff?cvsroot=src&r1=1.2&r2=NONE
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/efi-rtdrv-ia32.c.diff?cvsroot=src&r1=1.2&r2=NONE
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/efi-rtdrv-ia64.c.diff?cvsroot=src&r1=1.2&r2=NONE
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/efi-rtdrv-x86_64.c.diff?cvsroot=src&r1=1.2&r2=NONE
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/binutils/ChangeLog.diff?cvsroot=src&r1=1.1453&r2=1.1454
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/binutils/NEWS.diff?cvsroot=src&r1=1.78&r2=1.79
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/binutils/objcopy.c.diff?cvsroot=src&r1=1.128&r2=1.129
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/binutils/doc/binutils.texi.diff?cvsroot=src&r1=1.143&r2=1.144

Comment 4 H.J. Lu 2009-04-17 13:50:29 UTC
Fixed.