This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Overlap error not generated for sections w/o content

On Sun, Jan 11, 2004 at 04:14:12PM +0200, Galit Heller wrote:
> If the linker script is erroneously written, so that the .stack load
> address is set to a value which overlaps that of another output section,
> no error is generated, since the SEC_ALLOC flag isn't set for .stack. E.g.

I think that's a linker bug.  Clearly, addresses of SEC_ALLOC sections
matter whether they are SEC_LOAD or not.  Hmm, looking at ChangeLog
entries, I see Nick made some changes in this area back in 1999.

Possibly the following is a better patch to fix the problem Nick found.
Nick, how's your memory?

      * ldlang.c (IGNORE_SECTION): Don't ignore SEC_ALLOC && !SEC_LOAD
      sections.  Do ignore SEC_NEVER_LOAD sections.
      (lang_size_sections_1): Remove test made redundant with the above.

Index: ld/ldlang.c
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.132
diff -u -p -r1.132 ldlang.c
--- ld/ldlang.c	3 Jan 2004 12:39:07 -0000	1.132
+++ ld/ldlang.c	12 Jan 2004 01:07:50 -0000
@@ -2762,8 +2762,8 @@ size_input_section (lang_statement_union
 #define IGNORE_SECTION(bfd, s) \
-  (((bfd_get_section_flags (bfd, s) & (SEC_ALLOC | SEC_LOAD))	\
-    != (SEC_ALLOC | SEC_LOAD))					\
+  (((bfd_get_section_flags (bfd, s) & (SEC_ALLOC | SEC_NEVER_LOAD))	\
+    != SEC_ALLOC)							\
    || bfd_section_size (bfd, s) == 0)
 /* Check to see if any allocated sections overlap with other allocated
@@ -2930,8 +2930,6 @@ lang_size_sections_1
 		       region, and some non default memory regions were
 		       defined, issue an error message.  */
 		    if (!IGNORE_SECTION (output_bfd, os->bfd_section)
-			&& (bfd_get_section_flags (output_bfd, os->bfd_section)
-			    & SEC_NEVER_LOAD) == 0
 			&& ! link_info.relocatable
 			&& check_regions
 			&& strcmp (os->region->name, DEFAULT_MEMORY_REGION) == 0

Alan Modra
IBM OzLabs - Linux Technology Centre

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]