This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[Fwd: [PATCH] cr16-elf: Patch for resolve the local symbols in gas]
- From: "M R Swami Reddy" <MR dot Swami dot Reddy at nsc dot com>
- To: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Thu, 23 Jul 2009 17:53:44 +0530
- Subject: [Fwd: [PATCH] cr16-elf: Patch for resolve the local symbols in gas]
Hi,
With the below patch ran the GAS test suite and no regressions:
===
> make check-gas
=== gas Summary ===
# of expected passes 137
../as-new 2.19.51.20090722
===
Thanks
Swami
-------- Original Message --------
Subject: [PATCH] cr16-elf: Patch for resolve the local symbols in gas
Date: Thu, 23 Jul 2009 17:49:55 +0530
From: M R Swami Reddy <MR.Swami.Reddy@nsc.com>
To: binutils@sourceware.org <binutils@sourceware.org>
Hello,
Attached cr16-elf target specific patch for gas and ld to resolve the
local symbols
in gas and remove the relocs on the same.
I will commit the same by tomorrow, if there no questions/suggestions
for this patch.
bfd/ChangeLog:
2009-07-23 M R Swami Reddy <MR.Swami.Reddy@nsc.com>
* elf32-cr16.c (elf_cr16_final_link_relocate): Add code to handle
to R_cr16_NUM32 relocation.
gas/ChangeLog:
2009-07-23 M R Swami Reddy <MR.Swami.Reddy@nsc.com>
* config/tc-cr16.c (md_apply_fix): Put the addend value alone in to
object file without symbol values.
(tc_gen_reloc): For local symbols resolved or its absolute
symbol, then set the
relocation type as NULL.
Index: tc-cr16.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-cr16.c,v
retrieving revision 1.7
diff -u -r1.7 tc-cr16.c
--- tc-cr16.c 22 Jun 2009 17:56:01 -0000 1.7
+++ tc-cr16.c 23 Jul 2009 12:02:48 -0000
@@ -523,6 +523,13 @@
arelent * reloc;
bfd_reloc_code_real_type code;
+ /* If symbols are local and reloved, then no relocation needed. */
+ if ( ((fixP->fx_addsy)
+ && (S_GET_SEGMENT (fixP->fx_addsy) == absolute_section))
+ || ((fixP->fx_subsy)
+ && (S_GET_SEGMENT (fixP->fx_subsy) == absolute_section)))
+ return NULL;
+
reloc = xmalloc (sizeof (arelent));
reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
@@ -728,39 +735,52 @@
md_apply_fix (fixS *fixP, valueT *valP, segT seg)
{
valueT val = * valP;
- char *buf = fixP->fx_frag->fr_literal + fixP->fx_where;
- fixP->fx_offset = 0;
-
- switch (fixP->fx_r_type)
- {
- case BFD_RELOC_CR16_NUM8:
- bfd_put_8 (stdoutput, (unsigned char) val, buf);
- break;
- case BFD_RELOC_CR16_NUM16:
- bfd_put_16 (stdoutput, val, buf);
- break;
- case BFD_RELOC_CR16_NUM32:
- bfd_put_32 (stdoutput, val, buf);
- break;
- case BFD_RELOC_CR16_NUM32a:
- bfd_put_32 (stdoutput, val, buf);
- break;
- default:
- /* We shouldn't ever get here because linkrelax is nonzero. */
- abort ();
- break;
- }
-
- fixP->fx_done = 0;
if (fixP->fx_addsy == NULL
&& fixP->fx_pcrel == 0)
fixP->fx_done = 1;
-
- if (fixP->fx_pcrel == 1
+ else if (fixP->fx_pcrel == 1
&& fixP->fx_addsy != NULL
&& S_GET_SEGMENT (fixP->fx_addsy) == seg)
fixP->fx_done = 1;
+ else
+ fixP->fx_done = 0;
+
+ if (fixP->fx_addsy != NULL && !fixP->fx_pcrel)
+ {
+ val = fixP->fx_offset;
+ fixP->fx_done = 1;
+ }
+
+ if (fixP->fx_done)
+ {
+ char *buf = fixP->fx_frag->fr_literal + fixP->fx_where;
+
+ fixP->fx_offset = 0;
+
+ switch (fixP->fx_r_type)
+ {
+ case BFD_RELOC_CR16_NUM8:
+ bfd_put_8 (stdoutput, (unsigned char) val, buf);
+ break;
+ case BFD_RELOC_CR16_NUM16:
+ bfd_put_16 (stdoutput, val, buf);
+ break;
+ case BFD_RELOC_CR16_NUM32:
+ bfd_put_32 (stdoutput, val, buf);
+ break;
+ case BFD_RELOC_CR16_NUM32a:
+ bfd_put_32 (stdoutput, val, buf);
+ break;
+ default:
+ /* We shouldn't ever get here because linkrelax is nonzero. */
+ abort ();
+ break;
+ }
+ fixP->fx_done = 0;
+ }
+ else
+ fixP->fx_offset = * valP;
}
/* The location from which a PC relative jump should be calculated,
Index: elf32-cr16.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cr16.c,v
retrieving revision 1.7
diff -u -r1.7 elf32-cr16.c
--- elf32-cr16.c 27 Nov 2008 12:26:49 -0000 1.7
+++ elf32-cr16.c 23 Jul 2009 12:08:13 -0000
@@ -1259,6 +1259,21 @@
| (bfd_get_32 (input_bfd, hit_data) & 0xf0ff));
}
+ else if (r_type == R_CR16_NUM32)
+ {
+ Rvalue1 = (bfd_get_32 (input_bfd, hit_data));
+
+ /* Add or subtract the offset value */
+ if (Rvalue1 & 0x80000000)
+ Rvalue -= (~Rvalue1 + 1) & 0xffffffff;
+ else
+ Rvalue += Rvalue1;
+
+ /* Check for Ranga */
+ if (Rvalue > 0xffffffff)
+ return bfd_reloc_overflow;
+ }
+
bfd_put_32 (input_bfd, Rvalue, hit_data);
}
break;