This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: vmlinux parse error 2.6.12.5
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: binutils at sourceware dot org
- Cc: Dave Korn <dave dot korn at artimi dot com>, 'Nicolas Pitre' <nico at cam dot org>,'Mirco Fuchs' <mircofuchs at web dot de>,linux-arm-kernel at lists dot arm dot linux dot org dot uk
- Date: Fri, 26 Aug 2005 10:06:49 +0930
- Subject: Re: vmlinux parse error 2.6.12.5
- References: <Pine.LNX.4.63.0508250936350.15345@localhost.localdomain> <SERRANOWJ5SbkoMOSfU000002e8@SERRANO.CAM.ARTIMI.COM>
On Thu, Aug 25, 2005 at 04:22:28PM +0100, Dave Korn wrote:
> If the proc and arch info were on their own in output sections, we could
> test that, but attempting to use sizeof on the input sections like so:
>
> ---------------------<quote>---------------------
> ASSERT (!SIZEOF(.proc.info), "missing CPU support")
> ASSERT (!SIZEOF(.arch.info), "no machine record defined")
> ---------------------<quote>---------------------
You can't reference input sections. The arg of SIZEOF, ADDR, LOADADDR
is always an output section. So you are in fact referencing a
non-existent output section.
> produced the following result:
>
> ---------------------<snip!>---------------------
> /artimi/swtools/windows/bin/arm-linux-ld: internal error
> /repository/armtools/binutils-2.15/ld/ldexp.c 745
> ---------------------<snip!>---------------------
I'm not sure why 2.15 is giving you this. I know we've fixed a number
of bugs relating to non-existent output sections, and a bug in printing
assert statements if -Map is requested.
> to me that we still have the same problem: ASSERT is evaluated early, long
> before symbols have values assigned to them, but also long before the input
> sections have been placed in output sections, so I don't see how SIZEOF
> could be usable in an ASSERT either. I can only assume that the testcase
No, ASSERT is evaluated at various stages of the link process. Which is
probably not the right thing to do, as it means multiple messages can be
emitted. We also don't fail the assertion if the expression can't be
evaluated for some reason. I think that ought to be fixed too.
After this patch
ASSERT (ADDR (nonexistent) == 0, "don't be silly")
ASSERT (ADDR (nonexistent) != 0, "don't be silly")
ASSERT (SIZEOF (nonexistent) != 0, "don't be silly")
all give one "don't be silly" each and a link failure, while
ASSERT (SIZEOF (nonexistent) == 0, "don't be silly")
passes.
* ldexp.c (fold_name <SIZEOF>): Return 0 for non-existent section.
(exp_fold_tree_1): Print assert message only in final stage of
linking. Trigger assertion failure if expression cannot be
evaluated.
Index: ld/ldexp.c
===================================================================
RCS file: /cvs/src/src/ld/ldexp.c,v
retrieving revision 1.54
diff -u -p -r1.54 ldexp.c
--- ld/ldexp.c 5 Aug 2005 13:52:13 -0000 1.54
+++ ld/ldexp.c 26 Aug 2005 00:15:11 -0000
@@ -590,7 +590,9 @@ fold_name (etree_type *tree)
lang_output_section_statement_type *os;
os = lang_output_section_find (tree->name.name);
- if (os != NULL && os->processed > 0)
+ if (os == NULL)
+ new_abs (0);
+ else if (os->processed > 0)
new_abs (os->bfd_section->size / opb);
}
break;
@@ -655,15 +657,8 @@ exp_fold_tree_1 (etree_type *tree)
case etree_assert:
exp_fold_tree_1 (tree->assert_s.child);
- if (expld.result.valid_p)
- {
- if (expld.phase == lang_mark_phase_enum)
- /* We don't care if assert fails or not when we are just
- marking if a section is used or not. */
- expld.result.value = 1;
- else if (!expld.result.value)
- einfo ("%X%P: %s\n", tree->assert_s.message);
- }
+ if (expld.phase == lang_final_phase_enum && !expld.result.value)
+ einfo ("%X%P: %s\n", tree->assert_s.message);
break;
case etree_unary:
--
Alan Modra
IBM OzLabs - Linux Technology Centre