elf32-hppa shared lib support part 10

Alan Modra alan@linuxcare.com.au
Mon Sep 4 21:07:00 GMT 2000


The ld side of the shared lib support.

ld/ChangeLog
	* emultempl/hppaelf.em (hppaelf_add_stub_section): Add SEC_RELOC
	to stub section flags.
	(hppa_for_each_input_file_wrapper): New.
	(hppa_lang_for_each_input_file): New.
	(lang_for_each_input_file): Define to call above.
	(multi_subspace): New.
	(hppaelf_finish): Pass multi_subspace to elf32_hppa_size_stubs.
	(PARSE_AND_LIST_PROLOGUE): Define.
	(PARSE_AND_LIST_LONGOPTS): Define.
	(PARSE_AND_LIST_OPTIONS): Define.
	(PARSE_AND_LIST_ARGS_CASES): Define.
	(hppaelf_finish): Call elf32_hppa_set_gp.
	(hppaelf_set_output_arch): Remove.
	(LDEMUL_SET_OUTPUT_ARCH): Remove.

	* emulparams/hppalinux.sh (ELFSIZE): Define.
	(MACHINE): Define.
	(OTHER_READONLY_SECTIONS): Define.
	(DATA_PLT): Define.
	(GENERATE_SHLIB_SCRIPT): Define.

ld/testsuite/ChangeLog
	* ld-selective/selective.exp: Remove the xfails for hppa.

Alan Modra
-- 
Linuxcare.  Support for the Revolution.
 
diff -uprN -x*~ -xCVS -xTAGS -x.#* binutils-current/ld/emulparams/hppalinux.sh parisc/ld/emulparams/hppalinux.sh
--- binutils-current/ld/emulparams/hppalinux.sh	Thu Jul 27 15:06:11 2000
+++ parisc/ld/emulparams/hppalinux.sh	Wed Aug 16 08:58:45 2000
@@ -1,11 +1,16 @@
 SCRIPT_NAME=elf
+ELFSIZE=32
 OUTPUT_FORMAT="elf32-hppa"
 TEXT_START_ADDR=0x1000
 TARGET_PAGE_SIZE=0x1000
 MAXPAGESIZE=0x1000
 ARCH=hppa
+MACHINE=hppa1.1    # We use 1.1 specific features.
 NOP=0x08000240
 START="_start"
+OTHER_READONLY_SECTIONS='.PARISC.unwind : { *(.PARISC.unwind) } '
 DATA_START_SYMBOLS='$global$ = .;'
+DATA_PLT=
+GENERATE_SHLIB_SCRIPT=yes
 TEMPLATE_NAME=elf32
 EXTRA_EM_FILE=hppaelf
diff -uprN -x*~ -xCVS -xTAGS -x.#* binutils-current/ld/emultempl/hppaelf.em parisc/ld/emultempl/hppaelf.em
--- binutils-current/ld/emultempl/hppaelf.em	Thu Jul 27 15:18:23 2000
+++ parisc/ld/emultempl/hppaelf.em	Thu Aug 17 00:12:38 2000
@@ -27,7 +27,6 @@ cat >>e${EMULATION_NAME}.c <<EOF
 #include "ldctor.h"
 #include "elf32-hppa.h"
 
-static void hppaelf_set_output_arch PARAMS ((void));
 static void hppaelf_create_output_section_statements PARAMS ((void));
 static void hppaelf_delete_padding_statements
   PARAMS ((lang_statement_list_type *));
@@ -40,16 +39,11 @@ static void hppaelf_finish PARAMS ((void
 /* Fake input file for stubs.  */
 static lang_input_statement_type *stub_file;
 
+/* Type of import/export stubs to build.  For a single sub-space model,
+   we can build smaller import stubs and there is no need for export
+   stubs.  */
+static int multi_subspace = 0;
 
-/* Set the output architecture and machine.  */
-
-static void
-hppaelf_set_output_arch ()
-{
-  unsigned long machine = 0;
-
-  bfd_set_arch_mach (output_bfd, ldfile_output_architecture, machine);
-}
 
 /* This is called before the input files are opened.  We create a new
    fake input file to hold the stub sections.  */
@@ -233,7 +227,7 @@ hppaelf_add_stub_section (stub_name, inp
     goto err_ret;
 
   flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE
-	   | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_KEEP);
+	   | SEC_HAS_CONTENTS | SEC_RELOC | SEC_IN_MEMORY | SEC_KEEP);
   if (!bfd_set_section_flags (stub_file->the_bfd, stub_sec, flags))
     goto err_ret;
 
@@ -295,6 +289,7 @@ hppaelf_finish ()
 
   /* Call into the BFD backend to do the real work.  */
   if (! elf32_hppa_size_stubs (stub_file->the_bfd,
+			       multi_subspace,
 			       &link_info,
 			       &hppaelf_add_stub_section,
 			       &hppaelf_layaout_sections_again))
@@ -303,18 +298,76 @@ hppaelf_finish ()
       return;
     }
 
+  /* Set the global data pointer.  */
+  if (! elf32_hppa_set_gp (output_bfd, &link_info))
+    {
+      einfo ("%X%P: can not set gp\n");
+      return;
+    }
+
   /* Now build the linker stubs.  */
   if (stub_file->the_bfd->sections != NULL)
     {
-      if (! elf32_hppa_build_stubs (stub_file->the_bfd, &link_info))
+      if (! elf32_hppa_build_stubs (&link_info))
 	einfo ("%X%P: can not build stubs: %E\n");
     }
 }
 
+
+/* Avoid processing the fake stub_file in vercheck, stat_needed and
+   check_needed routines.  */
+
+static void hppa_for_each_input_file_wrapper
+  PARAMS ((lang_input_statement_type *));
+static void hppa_lang_for_each_input_file
+  PARAMS ((void (*) (lang_input_statement_type *)));
+
+static void (*real_func) PARAMS ((lang_input_statement_type *));
+
+static void hppa_for_each_input_file_wrapper (l)
+     lang_input_statement_type *l;
+{
+  if (l != stub_file)
+    (*real_func) (l);
+}
+
+static void
+hppa_lang_for_each_input_file (func)
+     void (*func) PARAMS ((lang_input_statement_type *));
+{
+  real_func = func;
+  lang_for_each_input_file (&hppa_for_each_input_file_wrapper);
+}
+
+#define lang_for_each_input_file hppa_lang_for_each_input_file
+
 EOF
 
-# Put these routines in ld_${EMULATION_NAME}_emulation
+# Define some shell vars to insert bits of code into the standard elf
+# parse_args and list_options functions.
+#
+PARSE_AND_LIST_PROLOGUE='
+#define OPTION_MULTI_SUBSPACE		301
+'
+
+PARSE_AND_LIST_LONGOPTS='
+  { "multi-subspace", no_argument, NULL, OPTION_MULTI_SUBSPACE},
+'
+
+PARSE_AND_LIST_OPTIONS='
+  fprintf (file, _("\
+  --multi-subspace            Generate import and export stubs to support\n\
+                              multiple sub-space shared libraries\n"
+		   ));
+'
+
+PARSE_AND_LIST_ARGS_CASES='
+    case OPTION_MULTI_SUBSPACE:
+      multi_subspace = 1;
+      break;
+'
+
+# Put these extra hppaelf routines in ld_${EMULATION_NAME}_emulation
 #
-LDEMUL_SET_OUTPUT_ARCH=hppaelf_set_output_arch
 LDEMUL_FINISH=hppaelf_finish
 LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=hppaelf_create_output_section_statements
diff -uprN -x*~ -xCVS -xTAGS -x.#* binutils-current/ld/testsuite/ld-selective/selective.exp parisc/ld/testsuite/ld-selective/selective.exp
--- binutils-current/ld/testsuite/ld-selective/selective.exp	Mon Jul 10 18:56:05 2000
+++ parisc/ld/testsuite/ld-selective/selective.exp	Thu Aug 17 22:01:51 2000
@@ -46,8 +46,6 @@ if { [which $CXX] == 0 } {
     return
 }
 
-setup_xfail "hppa*-*-*"
-
 if { ![ld_compile "$CC $cflags" $srcdir/$subdir/1.c tmpdir/1.o]} {
     unresolved $test1
     return
@@ -74,8 +72,6 @@ if ![ld_simple_link $ld tmpdir/1.x "$ldf
 	}
     }
 }
-
-setup_xfail "hppa*-*-*"
 
 if { ![ld_compile "$CC $cflags" $srcdir/$subdir/2.c tmpdir/2.o]} {
     unresolved $test2



More information about the Binutils mailing list