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]

[RFA:] Fix arithmetic on DEFINED.


A very small fix, broken out of the other DEFINED() changes.
Tested mmix-knuth-mmixware, cris-axis-elf.  The test SEGV:s
before this change.

Ok to commit?

ld:
	* ldexp.c (fold_name) <case DEFINED>: Set section of result to
	abs_output_section.

ld/testsuite:
	* ld-scripts/defined2.d, ld-scripts/defined2.t: New test.
	* ld-scripts/defined.exp: Run defined2.

Index: ldexp.c
===================================================================
RCS file: /cvs/src/src/ld/ldexp.c,v
retrieving revision 1.24
diff -p -c -r1.24 ldexp.c
*** ldexp.c	28 Jun 2003 05:28:54 -0000	1.24
--- ldexp.c	8 Oct 2003 03:26:01 -0000
*************** fold_name (etree_type *tree,
*** 497,503 ****
  			  && (h->type == bfd_link_hash_defined
  			      || h->type == bfd_link_hash_defweak
  			      || h->type == bfd_link_hash_common));
! 	  result.section = 0;
  	  result.valid_p = TRUE;
  	}
        break;
--- 497,503 ----
  			  && (h->type == bfd_link_hash_defined
  			      || h->type == bfd_link_hash_defweak
  			      || h->type == bfd_link_hash_common));
! 	  result.section = abs_output_section;
  	  result.valid_p = TRUE;
  	}
        break;

Index: defined.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-scripts/defined.exp,v
retrieving revision 1.3
diff -p -c -r1.3 defined.exp
*** defined.exp	24 Jul 2001 11:07:10 -0000	1.3
--- defined.exp	8 Oct 2003 03:24:48 -0000
*************** if ![ld_simple_link $ld tmpdir/def "-T $
*** 53,55 ****
--- 53,58 ----
  	}
      }
  }
+
+ set prms_id 0
+ run_dump_test "defined2"
--- /dev/null	Tue Jan  1 05:00:00 1980
+++ defined2.t	Wed Oct  8 05:17:40 2003
@@ -0,0 +1,9 @@
+SECTIONS {
+	.text : { *(.text) sym1 = 3 - DEFINED (x); }
+	.data : { *(.data) }
+	.bss : { *(.bss) *(COMMON) }
+}
+defined1 = !DEFINED (x);
+defined2 = DEFINED (defined1) + 16;
+defined3 = DEFINED (defined2) * 256;
+defined4 = 0x200 - DEFINED (defined3);
--- /dev/null	Tue Jan  1 05:00:00 1980
+++ defined2.d	Wed Oct  8 05:18:33 2003
@@ -0,0 +1,18 @@
+#ld: -Tdefined2.t
+#nm: -B
+#source: phdrs.s
+
+# Check that arithmetic on DEFINED works.
+# Matching both A and T accounts for formats that can't tell a .text
+# symbol from an absolute symbol (mmo), but matches whatever section that
+# contains an address matching the value.  The symbol sym1 is supposed to
+# be in the .text section for all targets, though.
+
+#...
+0+1 [AT] defined1
+0+11 A defined2
+0+100 A defined3
+0+1ff A defined4
+#...
+0+3 T sym1
+#pass

brgds, H-P


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