This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
check section overlap on relocatable links
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: binutils <binutils at sources dot redhat dot com>
- Date: Wed, 21 Jan 2009 12:27:25 +0000
- Subject: check section overlap on relocatable links
This patch allows section overlap to be checked on a relocatable link. Usually
this is a silly thing to do, because all output sections are placed at 0.
However, for vxworks images it can be useful, as a non-default linker script may
be being used to place sections sequentially.
The patch changes the check_section_addresses flag to be trivalued, so we can
distinguish 'default' from explicitly off and explicitly on. When defaulted we
disable checking on relocatable linking (but it remains enabled on
non-relocatable links). Thus preserving the existing default behaviour.
tested in powerpc-elf. ok?
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery
2009-01-21 Nathan Sidwell <nathan@codesourcery.com>
* lexsup.c (parse_args): Set check_section_addresses to 1 or 0.
* ld.h (args_type): Make check_section_addresses a char.
ldlang.c (lang_process): Don't consider relocatable flag when
checking for overlap.
* ldmain.c (main): Default check_section_addresses to -1. Check it
for relocatable links.
* ld.texinfo (--check-sections): Update documentation.
Index: ld.h
===================================================================
RCS file: /cvs/src/src/ld/ld.h,v
retrieving revision 1.41
diff -c -3 -p -r1.41 ld.h
*** ld.h 31 May 2008 16:35:56 -0000 1.41
--- ld.h 21 Jan 2009 12:21:52 -0000
*************** typedef struct {
*** 167,176 ****
search. */
bfd_boolean warn_search_mismatch;
!
! /* If TRUE (the default) check section addresses, once compute,
! fpor overlaps. */
! bfd_boolean check_section_addresses;
/* If TRUE allow the linking of input files in an unknown architecture
assuming that the user knows what they are doing. This was the old
--- 167,175 ----
search. */
bfd_boolean warn_search_mismatch;
! /* If non-zero check section addresses, once computed,
! for overlaps. Relocatable links only check when this is > 0. */
! signed char check_section_addresses;
/* If TRUE allow the linking of input files in an unknown architecture
assuming that the user knows what they are doing. This was the old
Index: ld.texinfo
===================================================================
RCS file: /cvs/src/src/ld/ld.texinfo,v
retrieving revision 1.226
diff -c -3 -p -r1.226 ld.texinfo
*** ld.texinfo 16 Jan 2009 14:14:06 -0000 1.226
--- ld.texinfo 21 Jan 2009 12:22:01 -0000
*************** perform this check, and if it finds any
*** 1205,1210 ****
--- 1205,1213 ----
suitable error messages. The linker does know about, and does make
allowances for sections in overlays. The default behaviour can be
restored by using the command line switch @option{--check-sections}.
+ Section overlap is not usually checked for relocatable links. You can
+ force checking in that case by using the @option{--check-sections}
+ option.
@cindex cross reference table
@kindex --cref
Index: ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.298
diff -c -3 -p -r1.298 ldlang.c
*** ldlang.c 26 Nov 2008 01:04:17 -0000 1.298
--- ldlang.c 21 Jan 2009 12:22:03 -0000
*************** lang_process (void)
*** 6225,6232 ****
ldemul_finish ();
/* Make sure that the section addresses make sense. */
! if (! link_info.relocatable
! && command_line.check_section_addresses)
lang_check_section_addresses ();
lang_end ();
--- 6225,6231 ----
ldemul_finish ();
/* Make sure that the section addresses make sense. */
! if (command_line.check_section_addresses)
lang_check_section_addresses ();
lang_end ();
Index: ldmain.c
===================================================================
RCS file: /cvs/src/src/ld/ldmain.c,v
retrieving revision 1.133
diff -c -3 -p -r1.133 ldmain.c
*** ldmain.c 17 Aug 2008 03:12:50 -0000 1.133
--- ldmain.c 21 Jan 2009 12:22:04 -0000
*************** main (int argc, char **argv)
*** 251,257 ****
command_line.warn_mismatch = TRUE;
command_line.warn_search_mismatch = TRUE;
! command_line.check_section_addresses = TRUE;
/* We initialize DEMANGLING based on the environment variable
COLLECT_NO_DEMANGLE. The gcc collect2 program will demangle the
--- 251,257 ----
command_line.warn_mismatch = TRUE;
command_line.warn_search_mismatch = TRUE;
! command_line.check_section_addresses = -1;
/* We initialize DEMANGLING based on the environment variable
COLLECT_NO_DEMANGLE. The gcc collect2 program will demangle the
*************** main (int argc, char **argv)
*** 292,297 ****
--- 292,299 ----
if (link_info.relocatable)
{
+ if (command_line.check_section_addresses < 0)
+ command_line.check_section_addresses = 0;
if (command_line.relax)
einfo (_("%P%F: --relax and -r may not be used together\n"));
if (link_info.shared)
Index: lexsup.c
===================================================================
RCS file: /cvs/src/src/ld/lexsup.c,v
retrieving revision 1.108
diff -c -3 -p -r1.108 lexsup.c
*** lexsup.c 16 Jan 2009 14:14:06 -0000 1.108
--- lexsup.c 21 Jan 2009 12:22:06 -0000
*************** parse_args (unsigned argc, char **argv)
*** 1411,1420 ****
config.split_by_file = 1;
break;
case OPTION_CHECK_SECTIONS:
! command_line.check_section_addresses = TRUE;
break;
case OPTION_NO_CHECK_SECTIONS:
! command_line.check_section_addresses = FALSE;
break;
case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH:
command_line.accept_unknown_input_arch = TRUE;
--- 1411,1420 ----
config.split_by_file = 1;
break;
case OPTION_CHECK_SECTIONS:
! command_line.check_section_addresses = 1;
break;
case OPTION_NO_CHECK_SECTIONS:
! command_line.check_section_addresses = 0;
break;
case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH:
command_line.accept_unknown_input_arch = TRUE;