This is the mail archive of the binutils@sources.redhat.com 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


Hi Alan, Hi Galit,

> From Alan:
>
> 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.
> http://sources.redhat.com/ml/binutils/1999-11/msg00137.html
>
> Possibly the following is a better patch to fix the problem Nick found.
> Nick, how's your memory?

A bit vague, but I do recall working on this bit fo code.

>       * 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.

This looks like a very good change, so please do commit it.

: > From Alan:
: > 
: > We can't really do anything about this.  !SEC_ALLOC && !SEC_LOAD
: > sections are typically used for debug sections.  If we started checking
: > these, they would all clash.
:
: From Galit:
:
: Of course. The question is whether SEC_ALLOC could be automatically set
: for a section in which dot is incremented, as is done in lang_size_sections_1
: for output sections whose statement consists of an output section data
: expression
: e.g. .section_name : { BYTE(0); } .
: 
: I realize that the latter case is a more clear cut indication of the section
: needing to be allocated.

I agree however.  Either the section should become allocated or else a
warning should be issued that advancing dot has no effect inside an
unallocated section.  How about a patch like this:

Cheers
        Nick

2004-01-12  Nick Clifton  <nickc@redhat.com>

	* ldlang.c (lang_size_sections_1): If dot is advanced, then
	assume that the section should be allocated.

        
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.132
diff -c -3 -p -r1.132 ldlang.c
*** ld/ldlang.c	3 Jan 2004 12:39:07 -0000	1.132
--- ld/ldlang.c	12 Jan 2004 13:27:04 -0000
*************** lang_size_sections_1
*** 3207,3212 ****
--- 3207,3218 ----
  		    s = s->header.next;
  		  }
  
+ 		/* If dot is advanced, this implies that the section should
+ 		   have space allocated to it, unless the user has explicitly
+ 		   stated that the section should never be loaded.  */
+ 		if (!(output_section_statement->flags & (SEC_NEVER_LOAD | SEC_ALLOC)))
+ 		  output_section_statement->bfd_section->flags |= SEC_ALLOC;
+ 
  		dot = newdot;
  	      }
  	  }


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