From: Paul Brook <paul@codesourcery.com>
To: binutils@sources.redhat.com
Subject: [patch] SymbianOS Arm executables
Date: Wed, 09 Feb 2005 23:38:00 -0000 [thread overview]
Message-ID: <200502092035.43426.paul@codesourcery.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1576 bytes --]
arm-*-symbianelf executables are relocatable. This has a few implications:
- We need to write out absolute relocations, like we do with shared libraries.
- These need to be against a symbols because the RO and RW segments are
relocated independently. In most cases we use the section symbol.
- Imported data is addressed directly (with absolute relocations).
Most of the changes are arm-specific, however I did need to add a new
common-code flag to allow creation of the local dynamic symbols.
Tested on i686-linux, arm-none-eabi and arm-none-symbianelf.
Ok?
Paul
This depends on a previous patch for correct symbol ordering:
http://sourceware.org/ml/binutils/2005-02/msg00169.html
2005-02-09 Paul Brook <paul@codesourcery.com>
* elf-bfd.h (struct elf_link_hash_table): Add keep_local_dynsyms.
* elf.c (_bfd_elf_link_hash_table_init): Initialize it.
* elflink.c (bfd_elf_link_record_dynamic_symbol): Allow creation of
local dynamic symbols.
(bfd_elf_record_link_assignment): Allow creation of dynamic section
symbols in ecxecutables.
(_bfd_elf_link_renumber_dynsyms): Ditto.
(bfd_elf_final_link): Ditto.
* elf32-arm.c (elf32_arm_final_link_relocate): Copy absolute
relocations into SymbianOS executables.
(elf32_arm_check_relocs): Crate dynamic sections for SymbianOS
executables. Copy absolute relocations into SymbianOS executables.
(elf32_arm_adjust_dynamic_symbol): Don't create copy relocations
in symbian objects.
(allocate_dynrelocs): Copy relocations for SymbianOS executables.
Output dynamic symbols for symbols defined in linker scripts.
[-- Attachment #2: patch.symbian_exec --]
[-- Type: text/x-diff, Size: 6314 bytes --]
Index: bfd/elf-bfd.h
===================================================================
RCS file: /var/cvsroot/src-cvs/src/bfd/elf-bfd.h,v
retrieving revision 1.170
diff -u -p -r1.170 elf-bfd.h
--- bfd/elf-bfd.h 31 Jan 2005 22:53:24 -0000 1.170
+++ bfd/elf-bfd.h 9 Feb 2005 02:20:12 -0000
@@ -398,6 +398,10 @@ struct elf_link_hash_table
/* A linked list of BFD's loaded in the link. */
struct elf_link_loaded_list *loaded;
+
+ /* True if local symbols should be included in dynamic symbol tables
+ of executable objects. */
+ bfd_boolean keep_local_dynsyms;
};
/* Look up an entry in an ELF linker hash table. */
Index: bfd/elf.c
===================================================================
RCS file: /var/cvsroot/src-cvs/src/bfd/elf.c,v
retrieving revision 1.263
diff -u -p -r1.263 elf.c
--- bfd/elf.c 31 Jan 2005 23:13:18 -0000 1.263
+++ bfd/elf.c 9 Feb 2005 02:03:46 -0000
@@ -1493,6 +1493,7 @@ _bfd_elf_link_hash_table_init
table->tls_sec = NULL;
table->tls_size = 0;
table->loaded = NULL;
+ table->keep_local_dynsyms = FALSE;
ret = _bfd_link_hash_table_init (&table->root, abfd, newfunc);
table->root.type = bfd_link_elf_hash_table;
Index: bfd/elf32-arm.c
===================================================================
RCS file: /var/cvsroot/src-cvs/src/bfd/elf32-arm.c,v
retrieving revision 1.20
diff -u -p -r1.20 elf32-arm.c
--- bfd/elf32-arm.c 31 Jan 2005 17:50:20 -0000 1.20
+++ bfd/elf32-arm.c 9 Feb 2005 02:23:36 -0000
@@ -2352,7 +2352,7 @@ elf32_arm_final_link_relocate (reloc_how
/* When generating a shared object, these relocations are copied
into the output file to be resolved at run time. */
- if (info->shared
+ if ((info->shared || globals->symbian_p)
&& (input_section->flags & SEC_ALLOC)
&& (r_type != R_ARM_REL32
|| !SYMBOL_CALLS_LOCAL (info, h))
@@ -3985,6 +3985,14 @@ elf32_arm_check_relocs (bfd *abfd, struc
htab = elf32_arm_hash_table (info);
sreloc = NULL;
+ /* Create dynamic sections for SymbianOS executables so that we can
+ copy relocations. */
+ if (htab->symbian_p && ! htab->root.dynamic_sections_created)
+ {
+ if (! _bfd_elf_link_create_dynamic_sections (abfd, info))
+ return FALSE;
+ }
+
dynobj = elf_hash_table (info)->dynobj;
local_got_offsets = elf_local_got_offsets (abfd);
@@ -4117,7 +4125,7 @@ elf32_arm_check_relocs (bfd *abfd, struc
later (it is never cleared). We account for that
possibility below by storing information in the
relocs_copied field of the hash table entry. */
- if (info->shared
+ if ((info->shared || htab->symbian_p)
&& (sec->flags & SEC_ALLOC) != 0
&& ((r_type != R_ARM_PC24
&& r_type != R_ARM_PLT32
@@ -4377,7 +4385,9 @@ elf32_arm_adjust_dynamic_symbol (struct
asection * s;
unsigned int power_of_two;
struct elf32_arm_link_hash_entry * eh;
+ struct elf32_arm_link_hash_table *globals;
+ globals = elf32_arm_hash_table (info);
dynobj = elf_hash_table (info)->dynobj;
/* Make sure we know what is going on here. */
@@ -4442,8 +4452,10 @@ elf32_arm_adjust_dynamic_symbol (struct
/* If we are creating a shared library, we must presume that the
only references to the symbol are via the global offset table.
For such cases we need not do anything here; the relocations will
- be handled correctly by relocate_section. */
- if (info->shared)
+ be handled correctly by relocate_section. On SymbianOS executables
+ can reference data in shared objects directly, so we don't need to
+ do anything here. */
+ if (info->shared || globals->symbian_p)
return TRUE;
/* We must allocate the symbol in our .dynbss section, which will
@@ -4636,13 +4648,23 @@ allocate_dynrelocs (struct elf_link_hash
space for pc-relative relocs that have become local due to symbol
visibility changes. */
- if (info->shared)
+ if (info->shared || htab->symbian_p)
{
/* Discard relocs on undefined weak syms with non-default
visibility. */
if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
&& h->root.type == bfd_link_hash_undefweak)
eh->relocs_copied = NULL;
+ else if (htab->symbian_p && h->dynindx == -1
+ && h->root.type == bfd_link_hash_new)
+ {
+ /* Output absolute symbols so that we can create relocations
+ against them. For normal symbols we output a relocation
+ against the section that contains them. */
+ if (! bfd_elf_link_record_dynamic_symbol (info, h))
+ return FALSE;
+ }
+
}
else
{
@@ -5845,6 +5867,7 @@ elf32_arm_symbian_link_hash_table_create
/* The PLT entries are each three instructions. */
htab->plt_entry_size = 4 * NUM_ELEM (elf32_arm_symbian_plt_entry);
htab->symbian_p = 1;
+ htab->root.keep_local_dynsyms = 1;
}
return ret;
}
Index: bfd/elflink.c
===================================================================
RCS file: /var/cvsroot/src-cvs/src/bfd/elflink.c,v
retrieving revision 1.126
diff -u -p -r1.126 elflink.c
--- bfd/elflink.c 1 Feb 2005 01:11:14 -0000 1.126
+++ bfd/elflink.c 9 Feb 2005 02:07:31 -0000
@@ -386,7 +386,8 @@ bfd_elf_link_record_dynamic_symbol (stru
&& h->root.type != bfd_link_hash_undefweak)
{
h->forced_local = 1;
- return TRUE;
+ if (!elf_hash_table (info)->keep_local_dynsyms)
+ return TRUE;
}
default:
@@ -484,6 +485,6 @@ bfd_elf_record_link_assignment (bfd *out
if ((h->def_dynamic
|| h->ref_dynamic
- || info->shared)
+ || info->shared || elf_hash_table (info)->keep_local_dynsyms)
&& h->dynindx == -1)
{
if (! bfd_elf_link_record_dynamic_symbol (info, h))
@@ -667,7 +701,7 @@ _bfd_elf_link_renumber_dynsyms
{
unsigned long dynsymcount = 0;
- if (info->shared)
+ if (info->shared || elf_hash_table (info)->keep_local_dynsyms)
{
const struct elf_backend_data *bed = get_elf_backend_data (output_bfd);
asection *p;
@@ -8104,7 +8143,7 @@ bfd_elf_final_link (bfd *abfd, struct bf
long last_local = 0;
/* Write out the section symbols for the output sections. */
- if (info->shared)
+ if (info->shared || elf_hash_table (info)->keep_local_dynsyms)
{
asection *s;
next reply other threads:[~2005-02-09 20:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-09 23:38 Paul Brook [this message]
2005-02-10 15:58 ` Richard Earnshaw
2005-02-10 17:29 ` Paul Brook
2005-02-10 19:54 ` Richard Earnshaw
2005-02-11 15:15 Nick Clifton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200502092035.43426.paul@codesourcery.com \
--to=paul@codesourcery.com \
--cc=binutils@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).