elf section type & objcopy

Nathan Sidwell nathan@codesourcery.com
Thu Jan 28 17:34:00 GMT 2010


H.J., Nick,

Back in 2006 H.J. applied this bfd patch:
2006-04-26  H.J. Lu  <hongjiu.lu@intel.com>

	PR binutils/2593
	* elf.c (_bfd_elf_new_section_hook): Don't set section ELF type
	and flags if its BFD flags have been set.
	(_bfd_elf_init_private_section_data): Don't copy the output ELF
	section type from input if it has been set to something
	different.

The mailing list thread is http://sourceware.org/ml/binutils/2006-04/msg00302.html

this breaks the following behaviour of objcopy:
   objcopy --add-section .note=some-file in.o out.o

previously, the new .note section would get a section type of NOTES, because 
_bfd_elf_get_sec_type_attr got called and checks for special section names.  The 
above patch causes that not to happen, as objcopy used make_section_with_flags, 
passing non-zero flags in.  Yes, it's taken this long for someone to notice :)

The attached flag also sets SEC_LINKER_CREATED to force checking the section 
name and restores the original behaviour.

I've not checked whether setting the section type from the name this way is 
documented -- it should be if it is what we want to happen.  I also need to 
create a testcase for this patch.

I have verified that the attached patch causes no regressions -- HJ's test cases 
still pass, so I guess I've not broken the above fix.

Am I heading in the right direction?

nathan

-- 
Nathan Sidwell    ::   http://www.codesourcery.com   ::         CodeSourcery

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: all.diff
URL: <https://sourceware.org/pipermail/binutils/attachments/20100128/fd9b6885/attachment.ksh>


More information about the Binutils mailing list