aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-08-25 09:42:20 -0700
committerH.J. Lu <hjl.tools@gmail.com>2016-06-22 06:04:17 -0700
commitdc14c8980672194a1b329b5c35a7f781bc04a3f5 (patch)
treee3d6a419510c587892d5ca8abf5a7a199cd640fc /ld
parent6b1edb94fedc7103b4929354d27304d0bd756f49 (diff)
downloadgdb-users/hjl/sharable.zip
gdb-users/hjl/sharable.tar.gz
gdb-users/hjl/sharable.tar.bz2
Add PT_GNU_SHR/SHF_GNU_SHARABLE/SHN_GNU_SHARABLE_COMMON support to gas/ldusers/hjl/sharable
PT_GNU_SHR/SHF_GNU_SHARABLE/SHN_GNU_SHARABLE_COMMON are used to group data into a PT_GNU_SHR to improve performance on NUMA system.
Diffstat (limited to 'ld')
-rw-r--r--ld/emulparams/elf32_x86_64.sh1
-rw-r--r--ld/emulparams/elf64_ia64.sh1
-rw-r--r--ld/emulparams/elf_i386.sh1
-rw-r--r--ld/emulparams/elf_x86_64.sh1
-rw-r--r--ld/emultempl/elf32.em7
-rw-r--r--ld/ldmain.c1
-rw-r--r--ld/scripttempl/elf.sc35
7 files changed, 47 insertions, 0 deletions
diff --git a/ld/emulparams/elf32_x86_64.sh b/ld/emulparams/elf32_x86_64.sh
index 9050730..b5507e2 100644
--- a/ld/emulparams/elf32_x86_64.sh
+++ b/ld/emulparams/elf32_x86_64.sh
@@ -21,6 +21,7 @@ LARGE_SECTIONS=yes
LARGE_BSS_AFTER_BSS=
SEPARATE_GOTPLT="SIZEOF (.got.plt) >= 24 ? 24 : 0"
IREL_IN_PLT=
+SHARABLE_SECTIONS=yes
if [ "x${host}" = "x${target}" ]; then
case " $EMULATION_LIBPATH " in
diff --git a/ld/emulparams/elf64_ia64.sh b/ld/emulparams/elf64_ia64.sh
index 7e5e54d..d8cf531 100644
--- a/ld/emulparams/elf64_ia64.sh
+++ b/ld/emulparams/elf64_ia64.sh
@@ -37,3 +37,4 @@ OTHER_READONLY_SECTIONS="${OTHER_READONLY_SECTIONS}
# .dtors. They have to be next to .sbss/.sbss2/.sdata/.sdata2.
SMALL_DATA_CTOR=" "
SMALL_DATA_DTOR=" "
+SHARABLE_SECTIONS=yes
diff --git a/ld/emulparams/elf_i386.sh b/ld/emulparams/elf_i386.sh
index b08e661..2dd59fe 100644
--- a/ld/emulparams/elf_i386.sh
+++ b/ld/emulparams/elf_i386.sh
@@ -21,6 +21,7 @@ IREL_IN_PLT=
TINY_READONLY_SECTION="
.plt.got ${RELOCATING-0} : { *(.plt.got) }
"
+SHARABLE_SECTIONS=yes
# Linux modify the default library search path to first include
# a 32-bit specific directory.
diff --git a/ld/emulparams/elf_x86_64.sh b/ld/emulparams/elf_x86_64.sh
index 6055204..f1cca77 100644
--- a/ld/emulparams/elf_x86_64.sh
+++ b/ld/emulparams/elf_x86_64.sh
@@ -26,6 +26,7 @@ TINY_READONLY_SECTION="
.plt.got ${RELOCATING-0} : { *(.plt.got) }
.plt.bnd ${RELOCATING-0} : { *(.plt.bnd) }
"
+SHARABLE_SECTIONS=yes
if [ "x${host}" = "x${target}" ]; then
case " $EMULATION_LIBPATH " in
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 47fa549..152fb93 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -106,6 +106,7 @@ gld${EMULATION_NAME}_before_parse (void)
`if test -n "$CALL_NOP_BYTE" ; then echo link_info.call_nop_byte = $CALL_NOP_BYTE; fi`;
link_info.check_relocs_after_open_input = `if test "x${CHECK_RELOCS_AFTER_OPEN_INPUT}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
link_info.relro = DEFAULT_LD_Z_RELRO;
+ link_info.sharable_sections = `if test "$SHARABLE_SECTIONS" = "yes" ; then echo TRUE ; else echo FALSE ; fi`;
}
EOF
@@ -1854,6 +1855,12 @@ gld${EMULATION_NAME}_place_orphan (asection *s,
flagword flags;
asection *nexts;
+ /* Orphaned sharable sections won't have correct page
+ requirements. */
+ if (elf_section_flags (s) & SHF_GNU_SHARABLE)
+ einfo ("%F%P: unable to place orphaned sharable section %A (%B)\n",
+ s, s->owner);
+
if (!bfd_link_relocatable (&link_info)
&& link_info.combreloc
&& (s->flags & SEC_ALLOC))
diff --git a/ld/ldmain.c b/ld/ldmain.c
index e7a8dff..7be0999 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -285,6 +285,7 @@ main (int argc, char **argv)
#ifdef DEFAULT_FLAG_COMPRESS_DEBUG
link_info.compress_debug = COMPRESS_DEBUG_GABI_ZLIB;
#endif
+ link_info.sharable_sections = FALSE;
ldfile_add_arch ("");
emulation = get_emulation (argc, argv);
diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc
index f0c6439..24af0eb 100644
--- a/ld/scripttempl/elf.sc
+++ b/ld/scripttempl/elf.sc
@@ -308,6 +308,40 @@ STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
${RELOCATING+${USER_LABEL_PREFIX}_stack = .;}
*(.stack)
}"
+test "${SHARABLE_SECTIONS}" = "yes" && OTHER_READWRITE_SECTIONS="
+ ${OTHER_READWRITE_SECTIONS}
+ /* Sharable data sections. */
+ .sharable_data ${RELOCATING-0} : ${RELOCATING+ALIGN(${MAXPAGESIZE})}
+ {
+ ${RELOCATING+PROVIDE_HIDDEN (__sharable_data_start = .);}
+ *(.sharable_data${RELOCATING+ .sharable_data.* .gnu.linkonce.shrd.*})
+ /* Align here to ensure that the sharable data section ends at the
+ page boundary. */
+ ${RELOCATING+. = ALIGN(. != 0 ? ${MAXPAGESIZE} : 1);}
+ ${RELOCATING+PROVIDE_HIDDEN (__sharable_data_end = .);}
+ }
+"
+test "${SHARABLE_SECTIONS}" = "yes" && OTHER_BSS_SECTIONS="
+ ${OTHER_BSS_SECTIONS}
+ /* Sharable bss sections */
+ .sharable_bss ${RELOCATING-0} : ${RELOCATING+ALIGN(${MAXPAGESIZE})}
+ {
+ ${RELOCATING+PROVIDE_HIDDEN (__sharable_bss_start = .);}
+ *(.dynsharablebss)
+ *(.sharable_bss${RELOCATING+ .sharable_bss.* .gnu.linkonce.shrb.*})
+ *(SHARABLE_COMMON)
+ /* Align here to ensure that the sharable bss section ends at the
+ page boundary. */
+ ${RELOCATING+. = ALIGN(. != 0 ? ${MAXPAGESIZE} : 1);}
+ ${RELOCATING+PROVIDE_HIDDEN (__sharable_bss_end = .);}
+ }
+"
+test "${SHARABLE_SECTIONS}" = "yes" && REL_SHARABLE="
+ .rel.sharable_data ${RELOCATING-0} : { *(.rel.sharable_data${RELOCATING+ .rel.sharable_data.* .rel.gnu.linkonce.shrd.*}) }
+ .rela.sharable_data ${RELOCATING-0} : { *(.rela.sharable_data${RELOCATING+ .rela.sharable_data.* .rela.gnu.linkonce.shrd.*}) }
+ .rel.sharable_bss ${RELOCATING-0} : { *(.rel.sharable_bss${RELOCATING+ .rel.sharable_bss.* .rel.gnu.linkonce.shrb.*}) }
+ .rela.sharable_bss ${RELOCATING-0} : { *(.rela.sharable_bss${RELOCATING+ .rela.sharable_bss.* .rela.gnu.linkonce.shrb.*}) }
+"
TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})"
SHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})"
@@ -408,6 +442,7 @@ eval $COMBRELOCCAT <<EOF
.rel.got ${RELOCATING-0} : { *(.rel.got) }
.rela.got ${RELOCATING-0} : { *(.rela.got) }
${OTHER_GOT_RELOC_SECTIONS}
+ ${REL_SHARABLE}
${REL_SDATA}
${REL_SBSS}
${REL_SDATA2}