Relative expressions and ASSERT
H.J. Lu
hjl.tools@gmail.com
Thu Dec 16 22:43:00 GMT 2010
On Thu, Dec 16, 2010 at 3:02 AM, Alan Modra <amodra@gmail.com> wrote:
> On Wed, Dec 15, 2010 at 08:25:17PM -0800, H.J. Lu wrote:
>> On Thu, Aug 12, 2010 at 4:38 PM, Alan Modra <amodra@gmail.com> wrote:
>> > On Thu, Aug 12, 2010 at 08:47:25AM -0700, H.J. Lu wrote:
>> >> You can try the new linker on Linux kernel.
>> >
>> > An x86 2.6.35 kernel built without any differences.
>> >
>>
>> It caused:
>>
>> http://sourceware.org/bugzilla/show_bug.cgi?id=12327
>
> I was expecting this to cause some trouble. You can't avoid breaking
> some linker scripts when you change the linker expression evaluation
> rules (really, give it some rules rather than the adhoc mess that was
> there before). I wonder if I should have gone a little further, and
> removed the special case for expressions outside of an output section
> definition. It's what I really wanted to do, but ran into a number of
> testsuite failures in our own testsuite when I originally tried that.
> Now that we differentiate between plain numbers and absolute symbols,
> only one testcase needs adjusting.
>
> So, if I commit this, scripts like the testcase below will need some
> asjustment. On the other hand, sym1 = sym2 assignments should work
> like they used to outside of an output section statement, fixing the
> kernel problem and
> frv-linux FAIL: FRV uClinux PIC relocs to weak undefined symbols, pie linking
> frv-linux FAIL: FRV uClinux PIC relocs to weak undefined symbols, shared linking
>
> How to people feel about this for 2.21.1?
>
This patch works for me.
--
H.J.
--
ld/
2010-12-16 H.J. Lu <hongjiu.lu@intel.com>
PR ld/12327
* ldexp.c (exp_fold_tree_1): Don't make subexpressions absolute
on etree_name.
ld/testsuite/
2010-12-16 H.J. Lu <hongjiu.lu@intel.com>
PR ld/12327
* ld-scripts/defined.exp: Run defined4.
* ld-scripts/defined4.d: New.
* ld-scripts/defined4.s: Likewise.
* ld-scripts/defined4.t: Likewise.
-------------- next part --------------
ld/
2010-12-16 H.J. Lu <hongjiu.lu@intel.com>
PR ld/12327
* ldexp.c (exp_fold_tree_1): Don't make subexpressions absolute
on etree_name.
ld/testsuite/
2010-12-16 H.J. Lu <hongjiu.lu@intel.com>
PR ld/12327
* ld-scripts/defined.exp: Run defined4.
* ld-scripts/defined4.d: New.
* ld-scripts/defined4.s: Likewise.
* ld-scripts/defined4.t: Likewise.
diff --git a/ld/ldexp.c b/ld/ldexp.c
index de7f9f2..4376364 100644
--- a/ld/ldexp.c
+++ b/ld/ldexp.c
@@ -862,7 +862,8 @@ exp_fold_tree_1 (etree_type *tree)
/* Any value not inside an output section statement is an
absolute value. */
if (expld.result.valid_p
- && expld.section == bfd_abs_section_ptr)
+ && expld.section == bfd_abs_section_ptr
+ && tree->type.node_class != etree_name)
make_abs ();
}
diff --git a/ld/testsuite/ld-scripts/defined.exp b/ld/testsuite/ld-scripts/defined.exp
index 15cc079..5742ae9 100644
--- a/ld/testsuite/ld-scripts/defined.exp
+++ b/ld/testsuite/ld-scripts/defined.exp
@@ -66,4 +66,5 @@ if ![ld_simple_link $ld tmpdir/def "$LDFLAGS -T $srcdir/$subdir/defined.t tmpdir
set prms_id 0
run_dump_test "defined2"
run_dump_test "defined3"
+run_dump_test "defined4"
set LDFLAGS "$saved_LDFLAGS"
--- /dev/null 2010-12-14 15:22:59.420000000 -0800
+++ binutils/ld/testsuite/ld-scripts/defined4.d 2010-12-16 14:00:46.264217155 -0800
@@ -0,0 +1,10 @@
+#ld: -Tdefined4.t
+#nm: -B
+#source: defined4.s
+
+# Check that arithmetic on DEFINED works.
+#...
+0+0 D defined
+#...
+0+0 D defined1
+#pass
--- /dev/null 2010-12-14 15:22:59.420000000 -0800
+++ binutils/ld/testsuite/ld-scripts/defined4.s 2010-12-16 12:46:23.558273203 -0800
@@ -0,0 +1,4 @@
+ .globl defined
+ .data
+defined:
+ .word 0
--- /dev/null 2010-12-14 15:22:59.420000000 -0800
+++ binutils/ld/testsuite/ld-scripts/defined4.t 2010-12-16 12:46:45.236797081 -0800
@@ -0,0 +1,6 @@
+SECTIONS {
+ .text : { *(.text) }
+ .data : { *(.data) }
+ .bss : { *(.bss) *(COMMON) }
+}
+defined1 = defined;
More information about the Binutils
mailing list