Mon Jul 15 11:49:49 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
authorIan Lance Taylor <ian@airs.com>
Mon, 15 Jul 1996 15:58:00 +0000 (15:58 +0000)
committerIan Lance Taylor <ian@airs.com>
Mon, 15 Jul 1996 15:58:00 +0000 (15:58 +0000)
* emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Round
  the value of __start_SECNAME to the alignment required by the
  section to be placed.

ld/ChangeLog
ld/emultempl/elf32.em

index 0010899..0e2e6ce 100644 (file)
@@ -1,3 +1,9 @@
+Mon Jul 15 11:49:49 1996  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>
+
+       * emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Round
+       the value of __start_SECNAME to the alignment required by the
+       section to be placed.
+
 Tue Jul  9 12:09:02 1996  Ian Lance Taylor  <ian@cygnus.com>
 
        * configure.tgt (mips*el-*-elf*): Use elf32elmip.
index 71e34b5..fe0b1b9 100644 (file)
@@ -1,9 +1,12 @@
 # This shell script emits a C file. -*- C -*-
 # It does some substitutions.
+# This file is now misnamed, because it supports both 32 bit and 64 bit
+# ELF emulations.
+test -z "${ELFSIZE}" && ELFSIZE=32
 cat >e${EMULATION_NAME}.c <<EOF
 /* This file is is generated by a shell script.  DO NOT EDIT! */
 
-/* 32 bit ELF emulation code for ${EMULATION_NAME}
+/* ${ELFSIZE} bit ELF emulation code for ${EMULATION_NAME}
    Copyright (C) 1991, 93, 94, 95, 1996 Free Software Foundation, Inc.
    Written by Steve Chamberlain <sac@cygnus.com>
    ELF support by Ian Lance Taylor <ian@cygnus.com>
@@ -133,6 +136,7 @@ gld${EMULATION_NAME}_open_dynamic_archive (arch, search, entry)
 
 EOF
 if [ "x${host}" = "x${target}" ] ; then
+  if [ "x${DEFAULT_EMULATION}" = "x${EMULATION_NAME}" ] ; then
 cat >>e${EMULATION_NAME}.c <<EOF
 
 /* For a native linker, check the file /etc/ld.so.conf for directories
@@ -215,6 +219,7 @@ gld${EMULATION_NAME}_check_ld_so_conf (name)
 }
 
 EOF
+  fi
 fi
 cat >>e${EMULATION_NAME}.c <<EOF
 
@@ -287,11 +292,13 @@ gld${EMULATION_NAME}_after_open ()
        }
 EOF
 if [ "x${host}" = "x${target}" ] ; then
+  if [ "x${DEFAULT_EMULATION}" = "x${EMULATION_NAME}" ] ; then
 cat >>e${EMULATION_NAME}.c <<EOF
       lib_path = (const char *) getenv ("LD_LIBRARY_PATH");
       if (gld${EMULATION_NAME}_search_needed (lib_path, l->name))
        continue;
 EOF
+  fi
 fi
 cat >>e${EMULATION_NAME}.c <<EOF
       len = strlen (l->name);
@@ -311,10 +318,12 @@ cat >>e${EMULATION_NAME}.c <<EOF
        continue;
 EOF
 if [ "x${host}" = "x${target}" ] ; then
+  if [ "x${DEFAULT_EMULATION}" = "x${EMULATION_NAME}" ] ; then
 cat >>e${EMULATION_NAME}.c <<EOF
       if (gld${EMULATION_NAME}_check_ld_so_conf (l->name))
        continue;
 EOF
+  fi
 fi
 cat >>e${EMULATION_NAME}.c <<EOF
 
@@ -548,12 +557,12 @@ gld${EMULATION_NAME}_before_allocation ()
   rpath = command_line.rpath;
   if (rpath == NULL)
     rpath = (const char *) getenv ("LD_RUN_PATH");
-  if (! bfd_elf32_size_dynamic_sections (output_bfd,
-                                        command_line.soname,
-                                        rpath,
-                                        command_line.export_dynamic,
-                                        &link_info,
-                                        &sinterp))
+  if (! bfd_elf${ELFSIZE}_size_dynamic_sections (output_bfd,
+                                                command_line.soname,
+                                                rpath,
+                                                command_line.export_dynamic,
+                                                &link_info,
+                                                &sinterp))
     einfo ("%P%F: failed to set dynamic section sizes: %E\n");
 
   /* Let the user override the dynamic linker we are using.  */
@@ -676,7 +685,7 @@ gld${EMULATION_NAME}_find_exp_assignment (exp)
     case etree_assign:
       if (strcmp (exp->assign.dst, ".") != 0)
        {
-         if (! (bfd_elf32_record_link_assignment
+         if (! (bfd_elf${ELFSIZE}_record_link_assignment
                 (output_bfd, &link_info, exp->assign.dst,
                  exp->type.node_class == etree_provide ? true : false)))
            einfo ("%P%F: failed to record assignment to %s: %E\n",
@@ -711,6 +720,7 @@ gld${EMULATION_NAME}_find_exp_assignment (exp)
 static asection *hold_section;
 static lang_output_section_statement_type *hold_use;
 static lang_output_section_statement_type *hold_text;
+static lang_output_section_statement_type *hold_rodata;
 static lang_output_section_statement_type *hold_data;
 static lang_output_section_statement_type *hold_bss;
 static lang_output_section_statement_type *hold_rel;
@@ -769,6 +779,10 @@ gld${EMULATION_NAME}_place_orphan (file, s)
   else if (strncmp (secname, ".rel", 4) == 0
           && hold_rel != NULL)
     place = hold_rel;
+  else if ((s->flags & SEC_CODE) == 0
+          && (s->flags & SEC_READONLY) != 0
+          && hold_rodata != NULL)
+    place = hold_rodata;
   else if ((s->flags & SEC_READONLY) != 0
           && hold_text != NULL)
     place = hold_text;
@@ -807,7 +821,9 @@ gld${EMULATION_NAME}_place_orphan (file, s)
       symname = (char *) xmalloc (ps - secname + sizeof "__start_");
       sprintf (symname, "__start_%s", secname);
       lang_add_assignment (exp_assop ('=', symname,
-                                     exp_nameop (NAME, ".")));
+                                     exp_unop (ALIGN_K,
+                                               exp_intop ((bfd_vma) 1
+                                                          << s->alignment_power))));
     }
 
   if (! link_info.relocateable)
@@ -862,11 +878,14 @@ gld${EMULATION_NAME}_place_section (s)
 
   if (strcmp (os->name, ".text") == 0)
     hold_text = os;
+  else if (strcmp (os->name, ".rodata") == 0)
+    hold_rodata = os;
   else if (strcmp (os->name, ".data") == 0)
     hold_data = os;
   else if (strcmp (os->name, ".bss") == 0)
     hold_bss = os;
   else if (hold_rel == NULL
+          && os->bfd_section != NULL
           && strncmp (os->name, ".rel", 4) == 0)
     hold_rel = os;
 }