+2014-01-20 Guy Martin <gmsoft@tuxicoman.be>
+ Alan Modra <amodra@gmail.com>
+
+ * ldlang.h (lang_output_section_get): Define.
+ * ldlang.c (lang_output_section_get): Likewise.
+ (init_os): Set the output_section userdata to the output
+ section statement.
+ * emultempl/hppaelf.em: Use lang_output_section_get instead of
+ lang_output_section_find where applicable.
+ * emultempl/aarch64elf.em: Likewise.
+ * emultempl/aix.em: Likewise.
+ * emultempl/armelf.em: Likewise.
+ * emultempl/m68hc1xelf.em: Likewise.
+ * emultempl/metagelf.em: Likewise.
+ * emultempl/mipself.em: Likewise.
+ * emultempl/ppc64elf.em: Likewise.
+ * emultempl/spuelf.em: Likewise.
+
2014-01-17 Alan Modra <amodra@gmail.com>
* genscripts.sh (COMPILE_IN): Don't set if already set.
asection *stub_sec;
flagword flags;
asection *output_section;
- const char *secname;
lang_output_section_statement_type *os;
struct hook_stub_info info;
bfd_set_section_alignment (stub_file->the_bfd, stub_sec, 3);
output_section = input_section->output_section;
- secname = bfd_get_section_name (output_section->owner, output_section);
- os = lang_output_section_find (secname);
+ os = lang_output_section_get (output_section);
info.input_section = input_section;
lang_list_init (&info.add);
/* Remove this section from the list of the output section.
This assumes we know what the script looks like. */
is = NULL;
- os = lang_output_section_find (sec->output_section->name);
+ os = lang_output_section_get (sec->output_section);
if (os == NULL)
einfo ("%P%F: can't find output section %s\n",
sec->output_section->name);
asection *stub_sec;
flagword flags;
asection *output_section;
- const char *secname;
lang_output_section_statement_type *os;
struct hook_stub_info info;
bfd_set_section_alignment (stub_file->the_bfd, stub_sec, alignment_power);
output_section = input_section->output_section;
- secname = bfd_get_section_name (output_section->owner, output_section);
- os = lang_output_section_find (secname);
+ os = lang_output_section_get (output_section);
info.input_section = input_section;
lang_list_init (&info.add);
asection *stub_sec;
flagword flags;
asection *output_section;
- const char *secname;
lang_output_section_statement_type *os;
struct hook_stub_info info;
goto err_ret;
output_section = input_section->output_section;
- secname = bfd_get_section_name (output_section->owner, output_section);
- os = lang_output_section_find (secname);
+ os = lang_output_section_get (output_section);
info.input_section = input_section;
lang_list_init (&info.add);
asection *stub_sec;
flagword flags;
asection *output_section;
- const char *secname;
lang_output_section_statement_type *os;
struct hook_stub_info info;
goto err_ret;
output_section = tramp_section->output_section;
- secname = bfd_get_section_name (output_section->owner, output_section);
- os = lang_output_section_find (secname);
+ os = lang_output_section_get (output_section);
/* Try to put the new section at the same place as an existing
.tramp section. Such .tramp section exists in most cases and
asection *stub_sec;
flagword flags;
asection *output_section;
- const char *secname;
lang_output_section_statement_type *os;
struct hook_stub_info info;
goto err_ret;
output_section = input_section->output_section;
- secname = bfd_get_section_name (output_section->owner, output_section);
- os = lang_output_section_find (secname);
+ os = lang_output_section_get (output_section);
info.input_section = input_section;
lang_list_init (&info.add);
{
asection *stub_sec;
flagword flags;
- const char *secname;
lang_output_section_statement_type *os;
struct hook_stub_info info;
if (!bfd_set_section_flags (stub_bfd, stub_sec, flags))
goto err_ret;
- /* Create an output section statement. */
- secname = bfd_get_section_name (output_section->owner, output_section);
- os = lang_output_section_find (secname);
+ os = lang_output_section_get (output_section);
/* Initialize a statement list that contains only the new statement. */
lang_list_init (&info.add);
asection *stub_sec;
flagword flags;
asection *output_section;
- const char *secname;
lang_output_section_statement_type *os;
struct hook_stub_info info;
goto err_ret;
output_section = input_section->output_section;
- secname = bfd_get_section_name (output_section->owner, output_section);
- os = lang_output_section_find (secname);
+ os = lang_output_section_get (output_section);
info.input_section = input_section;
lang_list_init (&info.add);
lang_output_section_statement_type *os;
if (o != NULL)
- output_name = o->name;
- os = lang_output_section_find (output_name);
+ os = lang_output_section_get (o);
+ else
+ os = lang_output_section_find (output_name);
if (os == NULL)
{
os = gld${EMULATION_NAME}_place_orphan (s, output_name, 0);
return lang_memory_region_lookup (DEFAULT_MEMORY_REGION, FALSE);
}
+/* Get the output section statement directly from the userdata. */
+
+lang_output_section_statement_type *
+lang_output_section_get (const asection *output_section)
+{
+ return get_userdata (output_section);
+}
+
/* Find or create an output_section_statement with the given NAME.
If CONSTRAINT is non-zero match one with that constraint, otherwise
match any non-negative constraint. If CREATE, always make a
s->bfd_section->output_section = s->bfd_section;
s->bfd_section->output_offset = 0;
+ /* Set the userdata of the output section to the output section
+ statement to avoid lookup. */
+ get_userdata (s->bfd_section) = s;
+
/* If there is a base address, make sure that any sections it might
mention are initialized. */
if (s->addr_tree != NULL)
(const char *, lang_input_file_enum_type, const char *);
extern void lang_add_keepsyms_file
(const char *);
+extern lang_output_section_statement_type *lang_output_section_get
+ (const asection *);
extern lang_output_section_statement_type *lang_output_section_statement_lookup
(const char *, int, bfd_boolean);
extern lang_output_section_statement_type *next_matching_output_section_statement