This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Committed: new CRIS pseudo for TLS DTPOFF: .dtpoffd
- From: Hans-Peter Nilsson <hans-peter dot nilsson at axis dot com>
- To: binutils at sourceware dot org
- Date: Sun, 21 Dec 2008 21:20:15 +0100
- Subject: Committed: new CRIS pseudo for TLS DTPOFF: .dtpoffd
Where the last "d" stands for "dword"-size, i.e. 32-bit in the
CRIS naming scheme. Having a means to emit non-code DTPREL TLS
relocs is apparently of use for GCC when emitting debug info.
I'm not completely sure about the semantics, but it seems
trivial enough to implement with just a test-case as contract.
I re-used a pseudo implementation I found in the MIPS port
(which BTW seemed unnecessarily restricted in that it requires
the relocation to be against a symbol, while the semantics of a
local-dynamic offset is canonically offsettable: adding an
offset being, how I shall put it, distributive over the gcc
"address legitimization" transformation operation).
Committed.
gas:
* config/tc-cris.c (s_cris_dtpoff): New function.
(md_pseudo_table): Add "dtpoffd".
gas/testsuite:
* gas/cris/rd-dtpoffd1.d, gas/cris/rd-dtpoffd1.s: New test.
Index: gas/cris/rd-dtpoffd1.d
===================================================================
RCS file: gas/cris/rd-dtpoffd1.d
diff -N gas/cris/rd-dtpoffd1.d
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gas/cris/rd-dtpoffd1.d 21 Dec 2008 20:13:57 -0000
@@ -0,0 +1,17 @@
+#objdump: -sr
+#as: --em=criself
+
+# Checking .dtpoffd output.
+
+.*: file format .*-cris
+
+RELOCATION RECORDS FOR \[.text\]:
+OFFSET TYPE VALUE
+0+4 R_CRIS_32_DTPREL extsym\+0x0000002a
+0+c R_CRIS_32_DTPREL x\+0x00000002
+
+Contents of section .text:
+ 0000 54686973 00000000 69732061 00000000 .*
+ 0010 99665655 .*
+Contents of section .tdata:
+ 0000 00000000 .*
Index: gas/cris/rd-dtpoffd1.s
===================================================================
RCS file: gas/cris/rd-dtpoffd1.s
diff -N gas/cris/rd-dtpoffd1.s
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gas/cris/rd-dtpoffd1.s 21 Dec 2008 20:13:57 -0000
@@ -0,0 +1,16 @@
+; Check that .dtpoffd trivially works, for external (though presumably
+; module-local) and local symbols with offsets.
+
+ .section .tdata,"awT",@progbits
+ .type x, @object
+ .size x, 4
+x:
+ .dword 0
+
+ .text
+start:
+ .dword 0x73696854
+ .dtpoffd extsym+42
+ .dword 0x61207369
+ .dtpoffd x+2
+ .dword 0x55566699
Index: config/tc-cris.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-cris.c,v
retrieving revision 1.44
diff -p -u -r1.44 tc-cris.c
--- config/tc-cris.c 20 Dec 2008 00:27:35 -0000 1.44
+++ config/tc-cris.c 21 Dec 2008 20:12:24 -0000
@@ -148,6 +148,7 @@ static void s_syntax (int);
static void s_cris_file (int);
static void s_cris_loc (int);
static void s_cris_arch (int);
+static void s_cris_dtpoff (int);
/* Get ":GOT", ":GOTOFF", ":PLT" etc. suffixes. */
static void cris_get_reloc_suffix (char **, bfd_reloc_code_real_type *,
@@ -198,6 +199,7 @@ static enum cris_archs cris_arch = XCONC
const pseudo_typeS md_pseudo_table[] =
{
{"dword", cons, 4},
+ {"dtpoffd", s_cris_dtpoff, 4},
{"syntax", s_syntax, 0},
{"file", s_cris_file, 0},
{"loc", s_cris_loc, 0},
@@ -4213,6 +4215,30 @@ s_cris_loc (int dummy)
dwarf2_directive_loc (dummy);
}
+/* Worker for .dtpoffd: generate a R_CRIS_32_DTPREL reloc, as for
+ expr:DTPREL but for use in debug info. */
+
+static void
+s_cris_dtpoff (int bytes)
+{
+ expressionS ex;
+ char *p;
+
+ if (bytes != 4)
+ as_fatal (_("internal inconsistency problem: %s called for %d bytes"),
+ __FUNCTION__, bytes);
+
+ expression (&ex);
+
+ p = frag_more (bytes);
+ md_number_to_chars (p, 0, bytes);
+ fix_new_exp (frag_now, p - frag_now->fr_literal, bytes, &ex, FALSE,
+ BFD_RELOC_CRIS_32_DTPREL);
+
+ demand_empty_rest_of_line ();
+}
+
+
/* Translate a <arch> string (as common to --march=<arch> and .arch <arch>)
into an enum. If the string *STR is recognized, *STR is updated to point
to the end of the string. If the string is not recognized,