This is the mail archive of the binutils@sourceware.cygnus.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]

Re: [PATCH] Re: Link error with today's CVS binutils


On Tue, Jan 18, 2000 at 11:09:25AM -0500, Ian Lance Taylor wrote:
>    Date: Tue, 18 Jan 2000 08:03:12 -0800
>    From: "H . J . Lu" <hjl@valinux.com>
> 
>    > I think that checking the size of the section is not the right way to
>    > go here.  Instead, check for SEC_NEVER_LOAD.  Look at how
>    > SEC_NEVER_LOAD is handled in ldwrite.c.
> 
>    Thanks. How about this change? Since it looks like SEC_NEVER_LOAD is
>    only used by COFF, I left in the size check.
> 
> I think the size check is wrong, though.  That would make Nick's patch
> totally useless.
> 
> SEC_NEVER_LOAD is used for any section specified as NOLOAD in the
> linker script.  See wild_doit in ldlang.c.
> 

I see your point. It seems that wild_doit is for input sections.
wild_doit is never called on .klog since it is an output section.

        .klog (NOLOAD) :
        {
                PROVIDE (__KLOG_START = .);
                . = . + 0x00000400;
                PROVIDE (__KLOG_END = .);
        } > ram1

The SEC_NEVER_LOAD bit is not set on .klog.

Here is the new patch.

-- 
H.J. Lu (hjl@gnu.org)
---
Tue Jan 18 08:13:17 2000  H.J. Lu  <hjl@gnu.org>

	* ldlang.c (lang_size_sections): Also update the current
	address of a region if the SEC_NEVER_LOAD bit is not set.

Index: ldlang.c
===================================================================
RCS file: /work/cvs/gnu/binutils/ld/ldlang.c,v
retrieving revision 1.1.1.13
diff -u -p -r1.1.1.13 ldlang.c
--- ldlang.c	2000/01/13 19:36:06	1.1.1.13
+++ ldlang.c	2000/01/18 16:24:07
@@ -2823,10 +2823,16 @@ lang_size_sections (s, output_section_st
 	    /* Update dot in the region ?
 	       We only do this if the section is going to be allocated,
 	       since unallocated sections do not contribute to the region's
-	       overall size in memory.  */
+	       overall size in memory.
+	       
+	       If the SEC_NEVER_LOAD bit is not set, it will affect the
+	       addresses of sections after it. We have to update
+	       dot. */
 	    if (os->region != (lang_memory_region_type *) NULL
-		&& (bfd_get_section_flags (output_bfd, os->bfd_section)
-		    & (SEC_ALLOC | SEC_LOAD)))
+		&& ((bfd_get_section_flags (output_bfd, os->bfd_section)
+		     & SEC_NEVER_LOAD) == 0
+		    || (bfd_get_section_flags (output_bfd, os->bfd_section)
+			& (SEC_ALLOC | SEC_LOAD))))
 	      {
 		os->region->current = dot;
 		

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