From decc95fcc70d4aa8802293b489c75e2a8ae0437f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans-J=C3=B6rg=20Frieden?= Date: Tue, 10 Apr 2007 13:19:20 +0000 Subject: [PATCH] Added support for generating dynamic shared object to the AmigaOS target. Most notable changes: - In ppc_elf_additional_program_headers, modified ret=0 to ret=1 to add an additional section header for dynamic linking, since we need an additional PT_LOAD for the separate .text section. - In ppc_elf_create_got, removed the SEC_CODE flag from the .got section to prevent it from being moved into the executable section. We do not use -fpic and hence have no need for the blrl in the .got section. - In ppc_elf_finish_dynamic_symbol, removed the code that makes _DYNAMIC, _GLOBAL_OFFSET_TABLE_ and _PROCEDURE_LINKAGE_TABLE_ absolute, since we need them to be relocatable. --- bfd/elf32-amigaos.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/bfd/elf32-amigaos.c b/bfd/elf32-amigaos.c index 7862ce4..c0d215d 100644 --- a/bfd/elf32-amigaos.c +++ b/bfd/elf32-amigaos.c @@ -2434,11 +2434,16 @@ ppc_elf_additional_program_headers (abfd) asection *s; int ret; - ret = 0; + /* -HJF- 20070410 + This is an assumption. Since we separate .text and the + dynamic linkage stuff, we need an addition PT_LOAD and hence one + additional program header. */ + + ret = 1; s = bfd_get_section_by_name (abfd, ".interp"); if (s != NULL) - ++ret; + ret++; s = bfd_get_section_by_name (abfd, ".sbss2"); if (s != NULL && (s->flags & SEC_LOAD) != 0 && s->_raw_size > 0) @@ -2479,7 +2484,10 @@ ppc_elf_create_got (abfd, info) if (s == NULL) abort (); - flags = (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS | SEC_IN_MEMORY + /* -HJF 20070125- Removed the SEC_CODE to make it non-execute. We do not use the blrl in + the .got, and leaving it would place all data sections into the code + segment */ + flags = (SEC_ALLOC | SEC_LOAD /*| SEC_CODE*/ | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); if (!bfd_set_section_flags (abfd, s, flags)) return FALSE; @@ -4244,13 +4252,13 @@ ppc_elf_finish_dynamic_symbol (output_bfd, info, h, sym) #ifdef DEBUG fprintf (stderr, "\n"); #endif - +#if 0 // -HJF- 20070410 removed this, we need them to stay non-absolute /* Mark some specially defined symbols as absolute. */ if (strcmp (h->root.root.string, "_DYNAMIC") == 0 || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0 || strcmp (h->root.root.string, "_PROCEDURE_LINKAGE_TABLE_") == 0) sym->st_shndx = SHN_ABS; - +#endif return TRUE; }