[PATCH] further equate handling adjustment
Jan Beulich
JBeulich@novell.com
Fri Oct 21 14:21:00 GMT 2005
The previous patch for enhancing equate handling didn't go far enough
when it comes to symbol cloning: the underlying BFD symbol must be
cloned, too, as it stores namely the section the symbol is in (which
may change for different instances of the same [multiply defined]
symbol).
Additionally, this fixes PR/1387.
Built and tested on i686-pc-linux-gnu, x86_64-unknown-linux-gnu,
ia64-unknown-linux-gnu, and for a large number of cross targets.
Jan
gas/
2005-10-21 Jan Beulich <jbeulich@novell.com>
* read.c (assign_symbol): Also consider equates already
defined.
* symbols.c (symbol_clone): Also cone the underlying BFD
symbol.
* config/obj-coff.h (obj_symbol_clone_hook): New.
(coff_obj_symbol_clone_hook): Declare.
* config/obj-coff.c (coff_obj_symbol_clone_hook): New.
gas/testsuite/
2005-10-21 Jan Beulich <jbeulich@novell.com>
* gas/all/gas.exp: Don't xfail equiv1 test anymore.
---
/home/jbeulich/src/binutils/mainline/2005-10-20/gas/config/obj-coff.c 2005-08-18
08:51:27.000000000 +0200
+++ 2005-10-20/gas/config/obj-coff.c 2005-10-21 10:40:09.000000000
+0200
@@ -329,6 +329,18 @@ coff_obj_symbol_new_hook (symbolS *symbo
SF_SET_LOCAL (symbolP);
}
+void
+coff_obj_symbol_clone_hook (symbolS *newsymP, symbolS *orgsymP)
+{
+ long sz = (OBJ_COFF_MAX_AUXENTRIES + 1) * sizeof
(combined_entry_type);
+ combined_entry_type * s = xmalloc (sz);
+
+ memcpy (s, coffsymbol (symbol_get_bfdsym (orgsymP))->native, sz);
+ coffsymbol (symbol_get_bfdsym (newsymP))->native = s;
+
+ SF_SET (newsymP, SF_GET (orgsymP));
+}
+
/* Handle .ln directives. */
---
/home/jbeulich/src/binutils/mainline/2005-10-20/gas/config/obj-coff.h 2005-08-18
08:51:27.000000000 +0200
+++ 2005-10-20/gas/config/obj-coff.h 2005-10-21 10:29:32.000000000
+0200
@@ -164,6 +164,7 @@
#endif
#define obj_symbol_new_hook coff_obj_symbol_new_hook
+#define obj_symbol_clone_hook coff_obj_symbol_clone_hook
#define obj_read_begin_hook coff_obj_read_begin_hook
#include "bfd/libcoff.h"
@@ -383,6 +384,7 @@ extern void coff_frob_section
extern void coff_adjust_section_syms (bfd *, asection *, void *);
extern void coff_frob_file_after_relocs (void);
extern void coff_obj_symbol_new_hook (symbolS *);
+extern void coff_obj_symbol_clone_hook (symbolS *, symbolS *);
extern void coff_obj_read_begin_hook (void);
extern void obj_coff_section (int);
extern segT obj_coff_add_segment (const char *);
---
/home/jbeulich/src/binutils/mainline/2005-10-20/gas/read.c 2005-10-11
14:31:18.000000000 +0200
+++ 2005-10-20/gas/read.c 2005-10-20 17:00:12.000000000 +0200
@@ -2793,7 +2793,7 @@ assign_symbol (char *name, int mode)
#endif
}
- if (S_IS_DEFINED (symbolP))
+ if (S_IS_DEFINED (symbolP) || symbol_equated_p (symbolP))
{
/* Permit register names to be redefined. */
if ((mode != 0 || !S_IS_VOLATILE (symbolP))
---
/home/jbeulich/src/binutils/mainline/2005-10-20/gas/symbols.c 2005-10-11
14:31:18.000000000 +0200
+++ 2005-10-20/gas/symbols.c 2005-10-21 12:18:42.000000000 +0200
@@ -541,6 +541,7 @@ symbolS *
symbol_clone (symbolS *orgsymP, int replace)
{
symbolS *newsymP;
+ asymbol *bsymorg, *bsymnew;
/* Running local_symbol_convert on a clone that's not the one
currently
in local_hash would incorrectly replace the hash entry. Thus
the
@@ -548,11 +549,30 @@ symbol_clone (symbolS *orgsymP, int repl
depends on not encountering an unconverted symbol. */
if (LOCAL_SYMBOL_CHECK (orgsymP))
orgsymP = local_symbol_convert ((struct local_symbol *) orgsymP);
+ bsymorg = orgsymP->bsym;
know (S_IS_DEFINED (orgsymP));
newsymP = obstack_alloc (¬es, sizeof (*newsymP));
*newsymP = *orgsymP;
+ bsymnew = bfd_make_empty_symbol (bfd_asymbol_bfd (bsymorg));
+ if (bsymnew == NULL)
+ as_perror ("%s", "bfd_make_empty_symbol");
+ newsymP->bsym = bsymnew;
+ bsymnew->name = bsymorg->name;
+ bsymnew->flags = bsymorg->flags;
+ bsymnew->section = bsymorg->section;
+ bsymnew->udata.p = (PTR) newsymP;
+ bfd_copy_private_symbol_data (bfd_asymbol_bfd (bsymorg), bsymorg,
+ bfd_asymbol_bfd (bsymnew), bsymnew);
+
+#ifdef obj_symbol_clone_hook
+ obj_symbol_clone_hook (newsymP, orgsymP);
+#endif
+
+#ifdef tc_symbol_clone_hook
+ tc_symbol_clone_hook (newsymP, orgsymP);
+#endif
if (replace)
{
---
/home/jbeulich/src/binutils/mainline/2005-10-20/gas/testsuite/gas/all/gas.exp 2005-10-11
14:31:18.000000000 +0200
+++ 2005-10-20/gas/testsuite/gas/all/gas.exp 2005-10-20
17:22:12.000000000 +0200
@@ -34,8 +34,6 @@ if ![istarget hppa*-*-*] then {
gas_test_error "diff1.s" "" "difference of two undefined symbols"
}
-# PR/1387
-setup_xfail "*-*-*"
gas_test_error "equiv1.s" "" ".equiv for symbol already set to another
one"
gas_test_error "equiv2.s" "" ".equiv for symbol already set to an
expression"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: binutils-mainline-equate-2.patch
Type: application/octet-stream
Size: 4847 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20051021/5667c4fe/attachment.obj>
More information about the Binutils
mailing list