]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
ld/
authorRoland McGrath <roland@gnu.org>
Tue, 18 Dec 2012 20:43:44 +0000 (20:43 +0000)
committerRoland McGrath <roland@gnu.org>
Tue, 18 Dec 2012 20:43:44 +0000 (20:43 +0000)
* ld.texinfo (Options): Describe -Trodata-segment.
* ldlex.h (enum option_values): Add OPTION_TRODATA_SEGMENT.
* lexsup.c (ld_options, parse_args): Handle -Trodata-segment.
* scripttempl/elf.sc (RODATA_ADDR, SHLIB_RODATA_ADDR): Wrap
SEGMENT_START("rodata-segment", ...) + SIZEOF_HEADERS around the value.

ld/ChangeLog
ld/ld.texinfo
ld/ldlex.h
ld/lexsup.c
ld/scripttempl/elf.sc

index b889478689cc087effa3df070ecb6236a63f9f4f..cb6d5955d83cf6b68f4555835904262441622f35 100644 (file)
@@ -1,3 +1,11 @@
+2012-12-18  Roland McGrath  <mcgrathr@google.com>
+
+       * ld.texinfo (Options): Describe -Trodata-segment.
+       * ldlex.h (enum option_values): Add OPTION_TRODATA_SEGMENT.
+       * lexsup.c (ld_options, parse_args): Handle -Trodata-segment.
+       * scripttempl/elf.sc (RODATA_ADDR, SHLIB_RODATA_ADDR): Wrap
+       SEGMENT_START("rodata-segment", ...) + SIZEOF_HEADERS around the value.
+
 2012-12-11  Roland McGrath  <mcgrathr@google.com>
 
        * emulparams/elf_nacl.sh (nacl_rodata_addr): New shell function.
index dd3149c8df244dddd3f0529c2c89b0547821673e..71e909e4b61606d4ca8d1f855d9cd10a3ae1947b 100644 (file)
@@ -372,9 +372,9 @@ Adds @var{AUDITLIB} to the @code{DT_AUDIT} entry of the dynamic section.
 specified in the library.  If specified multiple times @code{DT_AUDIT}
 will contain a colon separated list of audit interfaces to use. If the linker
 finds an object with an audit entry while searching for shared libraries,
-it will add a corresponding @code{DT_DEPAUDIT} entry in the output file.  
+it will add a corresponding @code{DT_DEPAUDIT} entry in the output file.
 This option is only meaningful on ELF platforms supporting the rtld-audit
-interface.  
+interface.
 
 @ifset I960
 @cindex architectures
@@ -472,7 +472,7 @@ Adds @var{AUDITLIB} to the @code{DT_DEPAUDIT} entry of the dynamic section.
 specified in the library.  If specified multiple times @code{DT_DEPAUDIT}
 will contain a colon separated list of audit interfaces to use.  This
 option is only meaningful on ELF platforms supporting the rtld-audit interface.
-The -P option is provided for Solaris compatibility.  
+The -P option is provided for Solaris compatibility.
 
 @cindex entry point, from command line
 @kindex -e @var{entry}
@@ -1256,7 +1256,7 @@ option.
 @kindex --no-copy-dt-needed-entries
 @item --copy-dt-needed-entries
 @itemx --no-copy-dt-needed-entries
-This option affects the treatment of dynamic libraries referred to 
+This option affects the treatment of dynamic libraries referred to
 by DT_NEEDED tags @emph{inside} ELF dynamic libraries mentioned on the
 command line.  Normally the linker won't add a DT_NEEDED tag to the
 output binary for each library mentioned in a DT_NEEDED tag in an
@@ -1384,7 +1384,7 @@ the linker recursively marks as used any section referenced by their
 relocations.  See @samp{--entry} and @samp{--undefined}.
 
 This option can be set when doing a partial link (enabled with option
-@samp{-r}).  In this case the root of symbols kept must be explicitly 
+@samp{-r}).  In this case the root of symbols kept must be explicitly
 specified either by an @samp{--entry} or @samp{--undefined} option or by
 a @code{ENTRY} command in the linker script.
 
@@ -1827,6 +1827,13 @@ Same as @option{--section-start}, with @code{.bss}, @code{.data} or
 When creating an ELF executable or shared object, it will set the address
 of the first byte of the text segment.
 
+@kindex -Trodata-segment=@var{org}
+@item -Trodata-segment=@var{org}
+@cindex rodata segment origin, cmd line
+When creating an ELF executable or shared object for a target where
+the read-only data is in its own segment separate from the executable
+text, it will set the address of the first byte of the read-only data segment.
+
 @kindex --unresolved-symbols
 @item --unresolved-symbols=@var{method}
 Determine how to handle unresolved symbols.  There are four possible
@@ -2204,8 +2211,8 @@ allow their use in executable images as well, or to (probably pointlessly!)
 disallow it in object files, by using these two options.  Executable images
 generated with these long section names are slightly non-standard, carrying
 as they do a string table, and may generate confusing output when examined
-with non-GNU PE-aware tools, such as file viewers and dumpers.  However, 
-GDB relies on the use of PE long section names to find Dwarf-2 debug 
+with non-GNU PE-aware tools, such as file viewers and dumpers.  However,
+GDB relies on the use of PE long section names to find Dwarf-2 debug
 information sections in an executable image at runtime, and so if neither
 option is specified on the command-line, @command{ld} will enable long
 section names, overriding the default and technically correct behaviour,
@@ -2616,7 +2623,7 @@ Do not bind this image.
 @kindex --wdmdriver
 @item --wdmdriver
 The driver uses the MS Windows Driver Model.
+
 @kindex --tsaware
 @item --tsaware
 The image is Terminal Server aware.
@@ -3187,7 +3194,7 @@ systems come with three different memory setups @code{A}, @code{B} and
 @code{C}:
 @multitable @columnfractions .25 .25 .25 .25
 @item Section @tab Variant A @tab Variant B @tab Variant C
-@item .text @tab RAM @tab ROM @tab ROM 
+@item .text @tab RAM @tab ROM @tab ROM
 @item .rodata @tab RAM @tab ROM @tab ROM2
 @item .data @tab RAM @tab RAM/ROM @tab RAM/ROM2
 @item .bss @tab RAM @tab RAM @tab RAM
@@ -4765,7 +4772,7 @@ Region names are stored in a separate name space, and will not conflict
 with symbol names, file names, or section names.  Each memory region
 must have a distinct name within the @code{MEMORY} command.  However you can
 add later alias names to existing memory regions with the @ref{REGION_ALIAS}
-command.  
+command.
 
 @cindex memory region attributes
 The @var{attr} string is an optional list of attributes that specify
@@ -5286,7 +5293,7 @@ The target's default page size.
 So for example:
 
 @smallexample
-  .text ALIGN (CONSTANT (MAXPAGESIZE)) : @{ *(.text) @} 
+  .text ALIGN (CONSTANT (MAXPAGESIZE)) : @{ *(.text) @}
 @end smallexample
 
 will create a text section aligned to the largest page boundary
@@ -6353,12 +6360,12 @@ are sufficient to avoid the erratum in both the scalar and vector cases.
 @cindex ARM1176 erratum workaround
 @kindex --fix-arm1176
 @kindex --no-fix-arm1176
-The @samp{--fix-arm1176} switch enables a link-time workaround for an erratum 
-in certain ARM1176 processors.  The workaround is enabled by default if you 
-are targetting ARM v6 (excluding ARM v6T2) or earlier.  It can be disabled 
+The @samp{--fix-arm1176} switch enables a link-time workaround for an erratum
+in certain ARM1176 processors.  The workaround is enabled by default if you
+are targetting ARM v6 (excluding ARM v6T2) or earlier.  It can be disabled
 unconditionally by specifying @samp{--no-fix-arm1176}.
 
-Further information is available in the ``ARM1176JZ-S and ARM1176JZF-S 
+Further information is available in the ``ARM1176JZ-S and ARM1176JZF-S
 Programmer Advice Notice'' available on the ARM documentaion website at:
 http://infocenter.arm.com/.
 
@@ -6950,7 +6957,7 @@ When auto-export is in operation, @command{ld} will export all the non-local
 symbols known to belong to the system's runtime and libraries.  As it will
 often not be desirable to export all of a DLL's symbols, which may include
 private functions that are not part of any public interface, the command-line
-options listed above may be used to filter symbols out from the list for 
+options listed above may be used to filter symbols out from the list for
 exporting.  The @samp{--output-def} option can be used in order to see the
 final list of exported symbols with all exclusions taken into effect.
 
index 5e3d2fcf8696c47ed940c5f1ace6945edda681ac..923add7d83dc27ea90126ec1d769662d65e06b5e 100644 (file)
@@ -68,6 +68,7 @@ enum option_values
   OPTION_TDATA,
   OPTION_TTEXT,
   OPTION_TTEXT_SEGMENT,
+  OPTION_TRODATA_SEGMENT,
   OPTION_TRADITIONAL_FORMAT,
   OPTION_UR,
   OPTION_VERBOSE,
index fc410c9e301be9fb545a1210f075d687e1c6927f..824b2898a0984d5062fc65336722a326962e7da9 100644 (file)
@@ -405,13 +405,13 @@ static const struct ld_option ld_options[] =
   { {"pic-executable", no_argument, NULL, OPTION_PIE},
     '\0', NULL, NULL, TWO_DASHES },
   { {"sort-common", optional_argument, NULL, OPTION_SORT_COMMON},
-    '\0', N_("[=ascending|descending]"), 
-    N_("Sort common symbols by alignment [in specified order]"), 
+    '\0', N_("[=ascending|descending]"),
+    N_("Sort common symbols by alignment [in specified order]"),
     TWO_DASHES },
   { {"sort_common", no_argument, NULL, OPTION_SORT_COMMON},
     '\0', NULL, NULL, NO_HELP },
   { {"sort-section", required_argument, NULL, OPTION_SORT_SECTION},
-    '\0', N_("name|alignment"), 
+    '\0', N_("name|alignment"),
     N_("Sort sections by name or maximum alignment"), TWO_DASHES },
   { {"spare-dynamic-tags", required_argument, NULL, OPTION_SPARE_DYNAMIC_TAGS},
     '\0', N_("COUNT"), N_("How many tags to reserve in .dynamic section"),
@@ -441,6 +441,8 @@ static const struct ld_option ld_options[] =
     '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH },
   { {"Ttext-segment", required_argument, NULL, OPTION_TTEXT_SEGMENT},
     '\0', N_("ADDRESS"), N_("Set address of text segment"), ONE_DASH },
+  { {"Trodata-segment", required_argument, NULL, OPTION_TRODATA_SEGMENT},
+    '\0', N_("ADDRESS"), N_("Set address of rodata segment"), ONE_DASH },
   { {"unresolved-symbols=<method>", required_argument, NULL,
      OPTION_UNRESOLVED_SYMBOLS},
     '\0', NULL, N_("How to handle unresolved symbols.  <method> is:\n"
@@ -1189,6 +1191,9 @@ parse_args (unsigned argc, char **argv)
        case OPTION_TTEXT_SEGMENT:
          set_segment_start (".text-segment", optarg);
          break;
+       case OPTION_TRODATA_SEGMENT:
+         set_segment_start (".rodata-segment", optarg);
+         break;
        case OPTION_TRADITIONAL_FORMAT:
          link_info.traditional_format = TRUE;
          break;
index 51a655eed65ce128a7fda611f9147f6377fb7025..6b3d08f25ba73b2d4ac2afbe45a15cd635c23f09 100644 (file)
@@ -492,12 +492,26 @@ cat <<EOF
 EOF
 
 if test -n "${SEPARATE_CODE}"; then
+  if test -n "${RODATA_ADDR}"; then
+    RODATA_ADDR="\
+SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR}) + SIZEOF_HEADERS"
+  else
+    RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))}"
+    RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR})"
+  fi
+  if test -n "${SHLIB_RODATA_ADDR}"; then
+    SHLIB_RODATA_ADDR="\
+SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR}) + SIZEOF_HEADERS"
+  else
+    SHLIB_RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR})"
+    SHLIB_RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
+  fi
   cat <<EOF
   /* Adjust the address for the rodata segment.  We want to adjust up to
      the same address within the page on the next page up.  */
-  ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${RODATA_ADDR-ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))};}}}
-  ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_RODATA_ADDR-ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))};}}
-  ${CREATE_PIE+${RELOCATING+. = ${SHLIB_RODATA_ADDR-ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))};}}
+  ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${RODATA_ADDR};}}}
+  ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_RODATA_ADDR};}}
+  ${CREATE_PIE+${RELOCATING+. = ${SHLIB_RODATA_ADDR};}}
 EOF
   emit_early_ro
   emit_dyn
@@ -650,8 +664,8 @@ cat <<EOF
   .debug_ranges   0 : { *(.debug_ranges) }
 
   /* DWARF Extension.  */
-  .debug_macro    0 : { *(.debug_macro) } 
-  
+  .debug_macro    0 : { *(.debug_macro) }
+
   ${TINY_DATA_SECTION}
   ${TINY_BSS_SECTION}