This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
PATCH: Define `.gnu_bp_high_bound' symbols from ld.
- To: binutils at sources dot redhat dot com
- Subject: PATCH: Define `.gnu_bp_high_bound' symbols from ld.
- From: Greg McGary <greg at mcgary dot org>
- Date: Wed, 6 Sep 2000 17:39:05 -0700
If there's no good way to define .gnu_bp_high_bound symbols associated
with initialized data, then this is all we'll do in ld: define
high-bound symbols associated with commons.
If there turns out to be a way to handle data, then this patch
is subject to change. However, for now, I'd like to get this in.
Thanks,
Greg
2000-09-06 Greg McGary <greg@mcgary.org>
* ldlang.c (undefined_high_bound_syms_p, high_bound_suffix):
New variables.
(lang_find_undefined_high_bound_syms): New function.
(lang_common): Scan for undefined `.gnu_bp_high_bound' symbols.
(lang_one_common): Convert the `.gnu_bp_high_bound' symbol
associated with this common symbol to defined.
Index: ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.30
diff -u -p -r1.30 ldlang.c
--- ldlang.c 2000/09/05 03:21:16 1.30
+++ ldlang.c 2000/09/07 00:30:16
@@ -54,6 +54,8 @@ static struct obstack stat_obstack;
static const char *startup_file;
static lang_statement_list_type input_file_chain;
static boolean placed_commons = false;
+static boolean undefined_high_bound_syms_p = false;
+static char high_bound_suffix[] = ".gnu_bp_high_bound";
static lang_output_section_statement_type *default_common_section;
static boolean map_option_f;
static bfd_vma print_dot;
@@ -133,6 +135,8 @@ static void ignore_bfd_errors PARAMS ((c
static void lang_check PARAMS ((void));
static void lang_common PARAMS ((void));
static boolean lang_one_common PARAMS ((struct bfd_link_hash_entry *, PTR));
+static boolean lang_find_undefined_high_bound_syms
+ PARAMS ((struct bfd_link_hash_entry *, PTR));
static void lang_place_orphans PARAMS ((void));
static int topower PARAMS ((int));
static void lang_set_startof PARAMS ((void));
@@ -3501,6 +3505,10 @@ lang_common ()
&& ! command_line.force_common_definition)
return;
+ /* Determine if there are undefined high-bound symbols. We want to know
+ this so that we can avoid unnecessary work in lang_one_common. */
+ bfd_link_hash_traverse (link_info.hash, lang_find_undefined_high_bound_syms, (PTR) NULL);
+
if (! config.sort_common)
bfd_link_hash_traverse (link_info.hash, lang_one_common, (PTR) NULL);
else
@@ -3551,6 +3559,24 @@ lang_one_common (h, info)
h->u.def.section = section;
h->u.def.value = section->_cooked_size;
+ if (undefined_high_bound_syms_p)
+ {
+ /* Find an associated undefined high-bound symbol, and mark it
+ as defined with a value equal to the address of the datum
+ plus that datum's size. */
+ char *high_bound_name = xmalloc (sizeof (high_bound_suffix) + strlen (h->root.string));
+ struct bfd_link_hash_entry *hbh;
+ sprintf (high_bound_name, "%s%s", h->root.string, high_bound_suffix);
+ hbh = bfd_link_hash_lookup (link_info.hash, high_bound_name, false, false, true);
+ if (hbh)
+ {
+ hbh->type = bfd_link_hash_defined;
+ hbh->u.def.section = h->u.def.section;
+ hbh->u.def.value = h->u.def.value + size;
+ }
+ free (high_bound_name);
+ }
+
/* Increase the size of the section. */
section->_cooked_size += size;
@@ -3606,6 +3632,20 @@ lang_one_common (h, info)
minfo ("%B\n", section->owner);
}
+ return true;
+}
+
+static boolean
+lang_find_undefined_high_bound_syms (h, info)
+ struct bfd_link_hash_entry *h;
+ PTR info ATTRIBUTE_UNUSED;
+{
+ if (h->type == bfd_link_hash_undefined
+ && strstr (h->root.string, high_bound_suffix))
+ {
+ undefined_high_bound_syms_p = true;
+ return false;
+ }
return true;
}