This is the mail archive of the binutils@sourceware.cygnus.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]

[PATCH] Elf: record_link_assignment: try to keep symbol types when possible.


I recently noticed that a ld script command like:

  PROVIDE (foo = 0);

will make an ELF ld change the type of the symbol `foo' to OBJECT,
regardless of what it originally was. This happens in the
bfd/elflink.h:record_link_assignment routine. One undesirable side
effect is that objdump won't let one disassemble what's at the symbol
location, once an ELF ld incorporated it.

I came up with a patch that Richard Henderson helped me to
refine. Here it is.

./A

Fri Aug 27 18:31:14 1999  Alexandre Petit-Bianco  <apbianco@cygnus.com>

	* elflink.h (record_link_assignment): When possible, keep the
	original type of the symbol.

Index: elflink.h
===================================================================
RCS file: /cvs/binutils/binutils/bfd/elflink.h,v
retrieving revision 1.26
diff -u -p -r1.26 elflink.h
--- elflink.h	1999/08/17 07:50:30	1.26
+++ elflink.h	1999/08/28 01:27:19
@@ -2371,7 +2371,10 @@ NAME(bfd_elf,record_link_assignment) (ou
     h->verinfo.verdef = NULL;
 
   h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
-  h->type = STT_OBJECT;
+
+  /* When possible, keep the original type of the symbol */
+  if (h->type == STT_NOTYPE)
+    h->type = STT_OBJECT;
 
   if (((h->elf_link_hash_flags & (ELF_LINK_HASH_DEF_DYNAMIC
 				  | ELF_LINK_HASH_REF_DYNAMIC)) != 0

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