This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: elf section type & objcopy
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: Nick Clifton <nickc at redhat dot com>
- Cc: hongjiu dot lu at intel dot com, binutils <binutils at sources dot redhat dot com>
- Date: Fri, 29 Jan 2010 11:24:06 +0000
- Subject: Re: elf section type & objcopy
- References: <4B61CA7A.60503@codesourcery.com> <4B62BC3D.5050606@redhat.com>
Nick,
The attached flag also sets SEC_LINKER_CREATED to force checking the
section name and restores the original behaviour.
Am I heading in the right direction?
Definitely. It seems slightly counter-intuitive to say that a section
requested by the user is "linker created", so it would be worth adding a
comment to the code explaining why the flag is used. But apart from
that your solution seems fine to me.
Excellent. Here's a full patch, tested on arm-eabi, ok?
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery
2010-01-29 Nathan Sidwell <nathan@codesourcery.com>
* objcopy (copy_object): Set SEC_LINKER_CREATED when adding
sections.
testsuite/
* binutils-all/note-1.d: New.
* binutils-all/objcopy.exp: Add it.
Index: objcopy.c
===================================================================
RCS file: /cvs/src/src/binutils/objcopy.c,v
retrieving revision 1.141
diff -c -3 -p -r1.141 objcopy.c
*** objcopy.c 20 Jan 2010 00:09:13 -0000 1.141
--- objcopy.c 29 Jan 2010 11:24:42 -0000
*************** copy_object (bfd *ibfd, bfd *obfd, const
*** 1608,1614 ****
}
else
{
! padd->section = bfd_make_section_with_flags (obfd, padd->name, flags);
if (padd->section == NULL)
{
bfd_nonfatal_message (NULL, obfd, NULL,
--- 1608,1619 ----
}
else
{
! /* We use LINKER_CREATED here so that the backend hooks
! will create any special section type information,
! instead of presuming we know what we're doing merely
! because we set the flags. */
! padd->section = bfd_make_section_with_flags
! (obfd, padd->name, flags | SEC_LINKER_CREATED);
if (padd->section == NULL)
{
bfd_nonfatal_message (NULL, obfd, NULL,
Index: testsuite/binutils-all/objcopy.exp
===================================================================
RCS file: /cvs/src/src/binutils/testsuite/binutils-all/objcopy.exp,v
retrieving revision 1.63
diff -c -3 -p -r1.63 objcopy.exp
*** testsuite/binutils-all/objcopy.exp 20 Jan 2010 00:09:13 -0000 1.63
--- testsuite/binutils-all/objcopy.exp 29 Jan 2010 11:24:42 -0000
*************** if [is_elf_format] {
*** 835,840 ****
--- 835,841 ----
objcopy_test_readelf "ELF group" group-3.s
objcopy_test_readelf "ELF group" group-4.s
run_dump_test "copy-1"
+ run_dump_test "note-1"
}
run_dump_test "copy-2"
Index: testsuite/binutils-all/note-1.d
===================================================================
RCS file: testsuite/binutils-all/note-1.d
diff -N testsuite/binutils-all/note-1.d
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/binutils-all/note-1.d 29 Jan 2010 11:26:12 -0000
***************
*** 0 ****
--- 1,12 ----
+ #PROG: objcopy
+ #readelf: -S --wide
+ #objcopy: --add-section .note=$srcdir/note-1.d
+ #name: add notes section
+ #source: copytest.s
+
+ There are .*
+
+ Section Headers:
+ #...
+ \[[ 0-9]*\] .note NOTE 0*0000000 0*...... 0*000... .*
+ #...