This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
PATCH: Don't turn undefined symbols into local.
- To: binutils at sourceware dot cygnus dot com
- Subject: PATCH: Don't turn undefined symbols into local.
- From: "H . J . Lu" <hjl at lucon dot org>
- Date: Tue, 3 Jul 2001 17:52:07 -0700
When you use
# objcopy --keep-global-symbol foo foo.o
it tries to turn undefined symbols into local. But the only thing
it does is turn weak undefined into normal undefined. I don't think
it is intended Here is a patch. Any comments?
H.J.
-----
2001-07-03 H.J. Lu <hjl@gnu.org>
* objcopy.c (filter_symbols): Don't turn undefined symbols
into local.
Index: objcopy.c
===================================================================
RCS file: /work/cvs/gnu/binutils/binutils/objcopy.c,v
retrieving revision 1.22
diff -u -p -r1.22 objcopy.c
--- objcopy.c 2001/06/24 16:38:25 1.22
+++ objcopy.c 2001/07/04 00:41:58
@@ -723,6 +723,7 @@ filter_symbols (abfd, obfd, osyms, isyms
flagword flags = sym->flags;
const char *name = bfd_asymbol_name (sym);
int keep;
+ boolean undefined;
if (redefine_sym_list)
{
@@ -755,10 +756,12 @@ filter_symbols (abfd, obfd, osyms, isyms
}
}
+ undefined = bfd_is_und_section (bfd_get_section (sym));
+
if (remove_leading_char
&& ((flags & BSF_GLOBAL) != 0
|| (flags & BSF_WEAK) != 0
- || bfd_is_und_section (bfd_get_section (sym))
+ || undefined
|| bfd_is_com_section (bfd_get_section (sym)))
&& name[0] == bfd_get_symbol_leading_char (abfd))
name = bfd_asymbol_name (sym) = name + 1;
@@ -781,7 +784,7 @@ filter_symbols (abfd, obfd, osyms, isyms
keep = 1;
else if ((flags & BSF_GLOBAL) != 0 /* Global symbol. */
|| (flags & BSF_WEAK) != 0
- || bfd_is_und_section (bfd_get_section (sym))
+ || undefined
|| bfd_is_com_section (bfd_get_section (sym)))
keep = strip_symbols != STRIP_UNNEEDED;
else if ((flags & BSF_DEBUGGING) != 0) /* Debugging symbol. */
@@ -811,7 +814,7 @@ filter_symbols (abfd, obfd, osyms, isyms
sym->flags &=~ BSF_GLOBAL;
sym->flags |= BSF_WEAK;
}
- if (keep && (flags & (BSF_GLOBAL | BSF_WEAK))
+ if (keep && !undefined && (flags & (BSF_GLOBAL | BSF_WEAK))
&& (is_specified_symbol (name, localize_specific_list)
|| (keepglobal_specific_list != NULL
&& ! is_specified_symbol (name, keepglobal_specific_list))))