ld failure introduced with pr797 patch

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

ld failure introduced with pr797 patch

Alan Modra
Hi HJ,
  I believe your fix for PR797 is to blame for a ld problem which can be
demonstrated by building binutils for tic30-unknown-coff and running the
ld testsuite.  I see "+FAIL: check sections 1".  The linker script has

.const :
{
        *(.const)
        __etext = . ;
} > rom
.mdata : AT( ADDR(.const) + SIZEOF(.const) )
{
        __data = . ;
        *(.data);
        __edata = . ;
} > ram

.const is empty, so fails to have its output_section_statement fully
initialized.  This results in "nonconstant expression for load base".

--
Alan Modra
IBM OzLabs - Linux Technology Centre
Reply | Threaded
Open this post in threaded view
|

Re: ld failure introduced with pr797 patch

H.J. Lu-27
On Thu, Jun 02, 2005 at 09:37:20PM +0930, Alan Modra wrote:

> Hi HJ,
>   I believe your fix for PR797 is to blame for a ld problem which can be
> demonstrated by building binutils for tic30-unknown-coff and running the
> ld testsuite.  I see "+FAIL: check sections 1".  The linker script has
>
> .const :
> {
>         *(.const)
>         __etext = . ;
> } > rom
> .mdata : AT( ADDR(.const) + SIZEOF(.const) )
> {
>         __data = . ;
>         *(.data);
>         __edata = . ;
> } > ram
>
> .const is empty, so fails to have its output_section_statement fully
> initialized.  This results in "nonconstant expression for load base".
>

I missed load base. I am testing this patch.



H.J.
---
2005-06-02  H.J. Lu  <[hidden email]>

        * ldexp.c (exp_mark_used_section): Call fold_binary on
        etree_binary.

        * ldlang.c (lang_mark_used_section_1): Handle load base.

--- ld/ldexp.c.base 2005-06-02 06:33:30.000000000 -0700
+++ ld/ldexp.c 2005-06-02 07:53:53.000000000 -0700
@@ -1237,6 +1237,8 @@ align_n (bfd_vma value, bfd_vma align)
 void
 exp_mark_used_section (etree_type *tree, asection *current_section)
 {
+  bfd_vma dot = 0;
+
   switch (tree->type.node_class)
     {
     case etree_value:
@@ -1252,6 +1254,8 @@ exp_mark_used_section (etree_type *tree,
       break;
 
     case etree_binary:
+      fold_binary (tree, current_section, lang_allocating_phase_enum,
+   dot, &dot, TRUE);
       break;
 
     case etree_trinary:
@@ -1263,7 +1267,6 @@ exp_mark_used_section (etree_type *tree,
       if (tree->assign.dst[0] != '.' || tree->assign.dst[1] != 0)
  {
   etree_value_type result;
-  bfd_vma dot = 0;
 
   result = exp_fold_tree_1 (tree->assign.src,
     current_section,
--- ld/ldlang.c.base 2005-06-02 06:33:30.000000000 -0700
+++ ld/ldlang.c 2005-06-02 07:48:22.000000000 -0700
@@ -3065,7 +3065,12 @@ lang_mark_used_section_1
 
     os = &(s->output_section_statement);
     if (os->bfd_section != NULL)
-      lang_mark_used_section_1 (os->children.head, os);
+      {
+ lang_mark_used_section_1 (os->children.head, os);
+ if (os->load_base)
+  exp_mark_used_section (os->load_base,
+ bfd_abs_section_ptr);
+      }
   }
   break;
  case lang_wild_statement_enum: