For larger databases, users often only want their text to be placed in
hugepages. libhugetlbfs does not currenlty provide this mode, however,
so users have been working around it in ... odd ... ways. Add explicit
support for T-only relinking via new linker scripts for ppc64, x86 and
x86_64. Unfortunately, I do not think (with my knowledge, at least) that
ppc32 can support T-only, due to the limitation that the PLT must be
within 32M of the text segment, confirmed in testing and based upon the
comment in the elf32ppclinux.xBDT:

      /* Just move to the very next hugepage, rather than using a guard
       * page, because for ppc32 binaries we can't separate the text and
       * PLT by >32MB */

Signed-off-by: Nishanth Aravamudan <[EMAIL PROTECTED]>

diff --git a/ldscripts/elf64ppc.xT b/ldscripts/elf64ppc.xT
new file mode 100644
index 0000000..d6a8297
--- /dev/null
+++ b/ldscripts/elf64ppc.xT
@@ -0,0 +1,230 @@
+/* Linker script for normal executables with text in hugepages */
+OUTPUT_FORMAT("elf64-powerpc", "elf64-powerpc",
+             "elf64-powerpc")
+OUTPUT_ARCH(powerpc:common64)
+ENTRY(_start)
+SEARCH_DIR("/usr/powerpc64-linux-gnu/lib64"); SEARCH_DIR("/usr/local/lib64"); 
SEARCH_DIR("/lib64"); SEARCH_DIR("/usr/lib64"); 
SEARCH_DIR("/usr/powerpc64-linux-gnu/lib"); SEARCH_DIR("/usr/local/lib"); 
SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib");
+INPUT( -lhugetlbfs );
+PHDRS
+{
+  headers PT_PHDR PHDRS ;
+  interp PT_INTERP ;
+  htext PT_LOAD FILEHDR PHDRS FLAGS (0x00100005);
+  data PT_LOAD ;
+  dynamic PT_DYNAMIC ;
+  note PT_NOTE ;
+  /* this is the value of PT_GNU_EH_FRAME as defined in
+     usr/include/elf.h but binutils does not recognize that identifier
+     as it does other PT_ constants. */
+  eh_frame_hdr 1685382480 FLAGS (0x00000004);
+}
+SECTIONS
+{
+  /* Read-only sections, merged into text segment: */
+  __executable_start = 0x10000000; . = 0x10000000 + SIZEOF_HEADERS;
+  .interp         : { *(.interp) } :interp :htext
+  .note.SuSE      : { *(.note.SuSE) } :htext :note
+  .note.ABI-tag   : { *(.note.ABI-tag) } :htext :note
+  .hash           : { *(.hash) } :htext
+  .dynsym         : { *(.dynsym) } :htext
+  .dynstr         : { *(.dynstr) } :htext
+  .gnu.version    : { *(.gnu.version) } :htext
+  .gnu.version_d  : { *(.gnu.version_d) } :htext
+  .gnu.version_r  : { *(.gnu.version_r) } :htext
+  .rel.init       : { *(.rel.init) } :htext
+  .rela.init      : { *(.rela.init) } :htext
+  .rel.text       : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) } :htext
+  .rela.text      : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) } 
:htext
+  .rel.fini       : { *(.rel.fini) } :htext
+  .rela.fini      : { *(.rela.fini) } :htext
+  .rel.rodata     : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) } 
:htext
+  .rela.rodata    : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) } 
:htext
+  .rel.data.rel.ro   : { *(.rel.data.rel.ro*) } :htext
+  .rela.data.rel.ro   : { *(.rel.data.rel.ro*) } :htext
+  .rel.data       : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) } :htext
+  .rela.data      : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) } 
:htext
+  .rel.tdata     : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) } :htext
+  .rela.tdata    : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) } 
:htext
+  .rel.tbss      : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) } :htext
+  .rela.tbss     : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) } 
:htext
+  .rel.ctors      : { *(.rel.ctors) } :htext
+  .rela.ctors     : { *(.rela.ctors) } :htext
+  .rel.dtors      : { *(.rel.dtors) } :htext
+  .rela.dtors     : { *(.rela.dtors) } :htext
+  .rel.got        : { *(.rel.got) } :htext
+  .rela.got       : { *(.rela.got) } :htext
+  .rela.toc      : { *(.rela.toc) } :htext
+  .rel.sdata      : { *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) } :htext
+  .rela.sdata     : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) } 
:htext
+  .rel.sbss       : { *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) } :htext
+  .rela.sbss      : { *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) } 
:htext
+  .rel.sdata2     : { *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) } 
:htext
+  .rela.sdata2    : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) } 
:htext
+  .rel.sbss2      : { *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) } 
:htext
+  .rela.sbss2     : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) } 
:htext
+  .rel.bss        : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) } :htext
+  .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) } :htext
+  .rel.plt        : { *(.rel.plt) } :htext
+  .rela.plt       : { *(.rela.plt) } :htext
+  .rela.tocbss   : { *(.rela.tocbss) } :htext
+  .init           :
+  {
+    KEEP (*(.init))
+  }  :htext =0x60000000
+  .text           :
+  {
+    *(.text .stub .text.* .gnu.linkonce.t.*)
+    KEEP (*(.text.*personality*))
+    /* .gnu.warning sections are handled specially by elf32.em.  */
+    *(.gnu.warning)
+    *(.sfpr .glink)
+  } :htext =0x60000000
+  .fini           :
+  {
+    KEEP (*(.fini))
+  }  :htext =0x60000000
+  PROVIDE (__etext = .);
+  PROVIDE (_etext = .);
+  PROVIDE (etext = .);
+  .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) } :htext
+  .rodata1        : { *(.rodata1) } :htext
+  .sdata2         :
+  {
+    *(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
+  } :htext
+  .sbss2          : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) } :htext
+  .eh_frame_hdr : { *(.eh_frame_hdr) } :htext :eh_frame_hdr
+/*  .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) } :htext */
+/*  .gcc_except_table   : ONLY_IF_RO { *(.gcc_except_table 
.gcc_except_table.*) } :htext */
+
+  /* We don't maintain address congruence here, because saving
+   * hugepages is more important than saving executable size. */
+  . = ALIGN (. + 0x1000000, 0x10000000); /* Align to next 256MB slice */
+  /* Exception handling  */
+  .eh_frame       : /*ONLY_IF_RW*/ { KEEP (*(.eh_frame)) } :data
+  .gcc_except_table   : /*ONLY_IF_RW*/ { *(.gcc_except_table 
.gcc_except_table.*) } :data
+  /* Thread Local Storage sections  */
+  .tdata         : { *(.tdata .tdata.* .gnu.linkonce.td.*) } :data
+  .tbss                  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } 
:data
+  .preinit_array     :
+  {
+    PROVIDE /*_HIDDEN*/ (__preinit_array_start = .);
+    KEEP (*(.preinit_array))
+    PROVIDE /*_HIDDEN*/ (__preinit_array_end = .);
+  } :data
+  .init_array     :
+  {
+     PROVIDE /*_HIDDEN*/ (__init_array_start = .);
+     KEEP (*(SORT(.init_array.*)))
+     KEEP (*(.init_array))
+     PROVIDE /*_HIDDEN*/ (__init_array_end = .);
+  } :data
+  .fini_array     :
+  {
+    PROVIDE /*_HIDDEN*/ (__fini_array_start = .);
+    KEEP (*(.fini_array))
+    KEEP (*(SORT(.fini_array.*)))
+    PROVIDE /*_HIDDEN*/ (__fini_array_end = .);
+  } :data
+  .ctors          :
+  {
+    /* gcc uses crtbegin.o to find the start of
+       the constructors, so we make sure it is
+       first.  Because this is a wildcard, it
+       doesn't matter if the user does not
+       actually link against crtbegin.o; the
+       linker won't look for a file to match a
+       wildcard.  The wildcard also means that it
+       doesn't matter which directory crtbegin.o
+       is in.  */
+    KEEP (*crtbegin*.o(.ctors))
+    /* We don't want to include the .ctor section from
+       from the crtend.o file until after the sorted ctors.
+       The .ctor section from the crtend file contains the
+       end of ctors marker and it must be last */
+    KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors))
+    KEEP (*(SORT(.ctors.*)))
+    KEEP (*(.ctors))
+  } :data
+  .dtors          :
+  {
+    KEEP (*crtbegin*.o(.dtors))
+    KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
+    KEEP (*(SORT(.dtors.*)))
+    KEEP (*(.dtors))
+  } :data
+  .jcr            : { KEEP (*(.jcr)) } :data
+  .data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro*) } :data
+  .dynamic        : { *(.dynamic) } :dynamic :data
+/*  . = DATA_SEGMENT_RELRO_END (0, .);*/
+  .data           :
+  {
+    *(.data .data.* .gnu.linkonce.d.*)
+    KEEP (*(.gnu.linkonce.d.*personality*))
+    SORT(CONSTRUCTORS)
+  } :data
+  .data1          : { *(.data1)}  :data
+  .toc1                 ALIGN(8) : { *(.toc1) } :data
+  .opd          ALIGN(8) : { KEEP (*(.opd)) } :data
+  .got         ALIGN(8) : { *(.got .toc) } :data
+  /* We want the small data sections together, so single-instruction offsets
+     can access them all, and initialized data all before uninitialized, so
+     we can shorten the on-disk segment size.  */
+  .sdata          :
+  {
+    *(.sdata .sdata.* .gnu.linkonce.s.*)
+  } :data
+  _edata = .; PROVIDE (edata = .);
+  __bss_start = .;
+  .tocbss       ALIGN(8) : { *(.tocbss)} :data
+  .sbss           :
+  {
+    *(.dynsbss)
+    *(.sbss .sbss.* .gnu.linkonce.sb.*)
+    *(.scommon)
+  } :data
+  .plt            : { *(.plt) } :data
+  .bss            :
+  {
+   *(.dynbss)
+   *(.bss .bss.* .gnu.linkonce.b.*)
+   *(COMMON)
+  } :data
+  _end = .;
+  PROVIDE (end = .);
+/*. = DATA_SEGMENT_END (.);*/
+  /* Stabs debugging sections.  */
+  .stab          0 : { *(.stab) }
+  .stabstr       0 : { *(.stabstr) }
+  .stab.excl     0 : { *(.stab.excl) }
+  .stab.exclstr  0 : { *(.stab.exclstr) }
+  .stab.index    0 : { *(.stab.index) }
+  .stab.indexstr 0 : { *(.stab.indexstr) }
+  .comment       0 : { *(.comment) }
+  /* DWARF debug sections.
+     Symbols in the DWARF debugging sections are relative to the beginning
+     of the section so we begin them at 0.  */
+  /* DWARF 1 */
+  .debug          0 : { *(.debug) }
+  .line           0 : { *(.line) }
+  /* GNU DWARF 1 extensions */
+  .debug_srcinfo  0 : { *(.debug_srcinfo) }
+  .debug_sfnames  0 : { *(.debug_sfnames) }
+  /* DWARF 1.1 and DWARF 2 */
+  .debug_aranges  0 : { *(.debug_aranges) }
+  .debug_pubnames 0 : { *(.debug_pubnames) }
+  /* DWARF 2 */
+  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
+  .debug_abbrev   0 : { *(.debug_abbrev) }
+  .debug_line     0 : { *(.debug_line) }
+  .debug_frame    0 : { *(.debug_frame) }
+  .debug_str      0 : { *(.debug_str) }
+  .debug_loc      0 : { *(.debug_loc) }
+  .debug_macinfo  0 : { *(.debug_macinfo) }
+  /* SGI/MIPS DWARF 2 extensions */
+  .debug_weaknames 0 : { *(.debug_weaknames) }
+  .debug_funcnames 0 : { *(.debug_funcnames) }
+  .debug_typenames 0 : { *(.debug_typenames) }
+  .debug_varnames  0 : { *(.debug_varnames) }
+  /DISCARD/ : { *(.note.GNU-stack) }
+}
diff --git a/ldscripts/elf_i386.xT b/ldscripts/elf_i386.xT
new file mode 100644
index 0000000..a84b66a
--- /dev/null
+++ b/ldscripts/elf_i386.xT
@@ -0,0 +1,197 @@
+/* Linker script for normal executables with text in hugepages */
+OUTPUT_FORMAT("elf32-i386", "elf32-i386",
+             "elf32-i386")
+OUTPUT_ARCH(i386)
+ENTRY(_start)
+SEARCH_DIR("/usr/i486-linux-gnu/lib"); SEARCH_DIR("/usr/local/lib"); 
SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib");
+INPUT(-lhugetlbfs);
+/* Do we need any of these for elf?
+   __DYNAMIC = 0;    */
+PHDRS
+{
+  headers PT_PHDR PHDRS ;
+  interp PT_INTERP ;
+  htext PT_LOAD FILEHDR PHDRS FLAGS (0x00100005);
+  data PT_LOAD ;
+  dynamic PT_DYNAMIC ;
+  note PT_NOTE ;
+  gnu_stack PT_GNU_STACK ;
+  /* this is the value of PT_GNU_EH_FRAME as defined in
+     usr/include/elf.h but binutils does not recognize that identifier
+     as it does other PT_ constants. */
+  eh_frame_hdr 1685382480 FLAGS (0x00000004);
+}
+SECTIONS
+{
+  /* Read-only sections, merged into text segment: */
+  /* Different from the normal origin addres, because we need to make
+   * it hugepage aligned */
+  __executable_start = 0x08000000; . = 0x08000000 + SIZEOF_HEADERS;
+  .interp         : { *(.interp) } :htext :interp
+  .note.SuSE      : { *(.note.SuSE) } :htext :note
+  .note.ABI-tag          : { *(.note.ABI-tag) } :htext :note
+  .hash           : { *(.hash) } :htext
+  .dynsym         : { *(.dynsym) } :htext
+  .dynstr         : { *(.dynstr) } :htext
+  .gnu.version    : { *(.gnu.version) } :htext
+  .gnu.version_d  : { *(.gnu.version_d) } :htext
+  .gnu.version_r  : { *(.gnu.version_r) } :htext
+  .rel.init       : { *(.rel.init) } :htext
+  .rela.init      : { *(.rela.init) } :htext
+  .rel.text       : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) } :htext
+  .rela.text      : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) } 
:htext
+  .rel.fini       : { *(.rel.fini) } :htext
+  .rela.fini      : { *(.rela.fini) } :htext
+  .rel.rodata     : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) } 
:htext
+  .rela.rodata    : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) } 
:htext
+  .rel.data.rel.ro   : { *(.rel.data.rel.ro*) } :htext
+  .rela.data.rel.ro   : { *(.rel.data.rel.ro*) } :htext
+  .rel.data       : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) } :htext
+  .rela.data      : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) } 
:htext
+  .rel.tdata     : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) } :htext
+  .rela.tdata    : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) } 
:htext
+  .rel.tbss      : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) } :htext
+  .rela.tbss     : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) } 
:htext
+  .rel.ctors      : { *(.rel.ctors) } :htext
+  .rela.ctors     : { *(.rela.ctors) } :htext
+  .rel.dtors      : { *(.rel.dtors) } :htext
+  .rela.dtors     : { *(.rela.dtors) } :htext
+  .rel.got        : { *(.rel.got) } :htext
+  .rela.got       : { *(.rela.got) } :htext
+  .rel.bss        : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) } :htext
+  .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) } :htext
+  .rel.plt        : { *(.rel.plt) } :htext
+  .rela.plt       : { *(.rela.plt) } :htext
+  .init           :
+  {
+    KEEP (*(.init))
+  }  :htext =0x90909090
+  .plt            : { *(.plt) }
+  .text           :
+  {
+    *(.text .stub .text.* .gnu.linkonce.t.*)
+    KEEP (*(.text.*personality*))
+    /* .gnu.warning sections are handled specially by elf32.em.  */
+    *(.gnu.warning)
+  }  :htext =0x90909090
+  .fini           :
+  {
+    KEEP (*(.fini))
+  }  :htext =0x90909090
+  PROVIDE (__etext = .);
+  PROVIDE (_etext = .);
+  PROVIDE (etext = .);
+  .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) } :htext
+  .rodata1        : { *(.rodata1) } :htext
+  .eh_frame_hdr : { *(.eh_frame_hdr) } :htext :eh_frame_hdr
+  /* .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) } :htext
+  .gcc_except_table   : ONLY_IF_RO { KEEP (*(.gcc_except_table)) 
*(.gcc_except_table.*) } :htext */
+
+  /* We don't maintain address congruence here, because saving
+   * hugepages is more important than saving executable size. */
+  . = ALIGN (0x1000000); /* Align to 16MB (4MB hugepage size, plus some slack 
in case of larger hugepages in future */
+  /* Exception handling  */
+  .eh_frame       : /* ONLY_IF_RW */ { KEEP (*(.eh_frame)) } :data
+  .gcc_except_table   : /* ONLY_IF_RW */ { KEEP (*(.gcc_except_table)) 
*(.gcc_except_table.*) } :data
+  /* Thread Local Storage sections  */
+  .tdata         : { *(.tdata .tdata.* .gnu.linkonce.td.*) } :data
+  .tbss                  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } 
:data
+  /* Ensure the __preinit_array_start label is properly aligned.  We
+     could instead move the label definition inside the section, but
+     the linker would then create the section even if it turns out to
+     be empty, which isn't pretty.  */
+  . = ALIGN(32 / 8);
+  PROVIDE (__preinit_array_start = .);
+  .preinit_array     : { KEEP (*(.preinit_array)) } :data
+  PROVIDE (__preinit_array_end = .);
+  PROVIDE (__init_array_start = .);
+  .init_array     : { KEEP (*(.init_array)) } :data
+  PROVIDE (__init_array_end = .);
+  PROVIDE (__fini_array_start = .);
+  .fini_array     : { KEEP (*(.fini_array)) } :data
+  PROVIDE (__fini_array_end = .);
+  .ctors          :
+  {
+    /* gcc uses crtbegin.o to find the start of
+       the constructors, so we make sure it is
+       first.  Because this is a wildcard, it
+       doesn't matter if the user does not
+       actually link against crtbegin.o; the
+       linker won't look for a file to match a
+       wildcard.  The wildcard also means that it
+       doesn't matter which directory crtbegin.o
+       is in.  */
+    KEEP (*crtbegin*.o(.ctors))
+    /* We don't want to include the .ctor section from
+       from the crtend.o file until after the sorted ctors.
+       The .ctor section from the crtend file contains the
+       end of ctors marker and it must be last */
+    KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors))
+    KEEP (*(SORT(.ctors.*)))
+    KEEP (*(.ctors))
+  } :data
+  .dtors          :
+  {
+    KEEP (*crtbegin*.o(.dtors))
+    KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
+    KEEP (*(SORT(.dtors.*)))
+    KEEP (*(.dtors))
+  } :data
+  .jcr            : { KEEP (*(.jcr)) } :data
+  .data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro*) } :data
+  .dynamic        : { *(.dynamic) } :dynamic :data
+  .got            : { *(.got.plt) *(.got) } :data
+  .data           :
+  {
+    *(.data .data.* .gnu.linkonce.d.*)
+    KEEP (*(.gnu.linkonce.d.*personality*))
+    SORT(CONSTRUCTORS)
+  } :data
+  .data1          : { *(.data1) } :data
+  _edata = .;
+  PROVIDE (edata = .);
+  . = ALIGN(32 / 8);
+  __bss_start = .;
+  .bss        :
+  {
+   *(.dynbss)
+   *(.bss .bss.* .gnu.linkonce.b.*)
+   *(COMMON)
+  }  :data
+  _end = .;
+  PROVIDE (end = .);
+  /* Stabs debugging sections.  */
+  .stab          0 : { *(.stab) }
+  .stabstr       0 : { *(.stabstr) }
+  .stab.excl     0 : { *(.stab.excl) }
+  .stab.exclstr  0 : { *(.stab.exclstr) }
+  .stab.index    0 : { *(.stab.index) }
+  .stab.indexstr 0 : { *(.stab.indexstr) }
+  .comment       0 : { *(.comment) }
+  /* DWARF debug sections.
+     Symbols in the DWARF debugging sections are relative to the beginning
+     of the section so we begin them at 0.  */
+  /* DWARF 1 */
+  .debug          0 : { *(.debug) }
+  .line           0 : { *(.line) }
+  /* GNU DWARF 1 extensions */
+  .debug_srcinfo  0 : { *(.debug_srcinfo) }
+  .debug_sfnames  0 : { *(.debug_sfnames) }
+  /* DWARF 1.1 and DWARF 2 */
+  .debug_aranges  0 : { *(.debug_aranges) }
+  .debug_pubnames 0 : { *(.debug_pubnames) }
+  /* DWARF 2 */
+  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
+  .debug_abbrev   0 : { *(.debug_abbrev) }
+  .debug_line     0 : { *(.debug_line) }
+  .debug_frame    0 : { *(.debug_frame) }
+  .debug_str      0 : { *(.debug_str) }
+  .debug_loc      0 : { *(.debug_loc) }
+  .debug_macinfo  0 : { *(.debug_macinfo) }
+  /* SGI/MIPS DWARF 2 extensions */
+  .debug_weaknames 0 : { *(.debug_weaknames) }
+  .debug_funcnames 0 : { *(.debug_funcnames) }
+  .debug_typenames 0 : { *(.debug_typenames) }
+  .debug_varnames  0 : { *(.debug_varnames) }
+  /DISCARD/ : { *(.note.GNU-stack) }
+}
diff --git a/ldscripts/elf_x86_64.xT b/ldscripts/elf_x86_64.xT
new file mode 100644
index 0000000..6d4e88e
--- /dev/null
+++ b/ldscripts/elf_x86_64.xT
@@ -0,0 +1,201 @@
+/* Linker script for normal executables with text in hugepages */
+OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64",
+             "elf64-x86-64")
+OUTPUT_ARCH(i386:x86-64)
+ENTRY(_start)
+SEARCH_DIR("/usr/x86_64-linux-gnu/lib64"); SEARCH_DIR("/usr/local/lib64"); 
SEARCH_DIR("/lib64"); SEARCH_DIR("/usr/lib64"); 
SEARCH_DIR("/usr/x86_64-linux-gnu/lib"); SEARCH_DIR("/usr/local/lib"); 
SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib");
+INPUT(-lhugetlbfs);
+/* Do we need any of these for elf?
+   __DYNAMIC = 0;    */
+PHDRS
+{
+  headers PT_PHDR PHDRS ;
+  interp PT_INTERP ;
+  htext PT_LOAD FILEHDR PHDRS FLAGS (0x00100005);
+  data PT_LOAD ;
+  dynamic PT_DYNAMIC ;
+  note PT_NOTE ;
+  gnu_stack PT_GNU_STACK ;
+  /* this is the value of PT_GNU_EH_FRAME as defined in
+     usr/include/elf.h but binutils does not recognize that identifier
+     as it does other PT_ constants. */
+  eh_frame_hdr 1685382480 FLAGS (0x00000004);
+}
+SECTIONS
+{
+  /* Read-only sections, merged into text segment: */
+  /* Different from the normal origin address, because we make it 16MB
+   * aligned, in case of future larger hugepages */
+  __executable_start = 0x1000000; . = 0x1000000 + SIZEOF_HEADERS;
+  .interp         : { *(.interp) } :interp :htext
+  .hash           : { *(.hash) } :htext
+  .note.SuSE      : { *(.note.SuSE) } :htext :note
+  .note.ABI-tag   : { *(.note.ABI-tag) } :htext :note
+  .dynsym         : { *(.dynsym) } :htext
+  .dynstr         : { *(.dynstr) } :htext
+  .gnu.version    : { *(.gnu.version) } :htext
+  .gnu.version_d  : { *(.gnu.version_d) } :htext
+  .gnu.version_r  : { *(.gnu.version_r) } :htext
+  .rel.init       : { *(.rel.init) } :htext
+  .rela.init      : { *(.rela.init) } :htext
+  .rel.text       : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) } :htext
+  .rela.text      : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) } 
:htext
+  .rel.fini       : { *(.rel.fini) } :htext
+  .rela.fini      : { *(.rela.fini) } :htext
+  .rel.rodata     : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) } 
:htext
+  .rela.rodata    : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) } 
:htext
+  .rel.data.rel.ro   : { *(.rel.data.rel.ro*) } :htext
+  .rela.data.rel.ro   : { *(.rel.data.rel.ro*) } :htext
+  .rel.data       : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) } :htext
+  .rela.data      : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) } 
:htext
+  .rel.tdata     : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) } :htext
+  .rela.tdata    : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) } 
:htext
+  .rel.tbss      : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) } :htext
+  .rela.tbss     : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) } 
:htext
+  .rel.ctors      : { *(.rel.ctors) } :htext
+  .rela.ctors     : { *(.rela.ctors) } :htext
+  .rel.dtors      : { *(.rel.dtors) } :htext
+  .rela.dtors     : { *(.rela.dtors) } :htext
+  .rel.got        : { *(.rel.got) } :htext
+  .rela.got       : { *(.rela.got) } :htext
+  .rel.bss        : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) } :htext
+  .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) } :htext
+  .rel.plt        : { *(.rel.plt) } :htext
+  .rela.plt       : { *(.rela.plt) } :htext
+  .init           :
+  {
+    KEEP (*(.init))
+  } :htext =0x90909090
+  .plt            : { *(.plt) } :htext
+  .text           :
+  {
+    *(.text .stub .text.* .gnu.linkonce.t.*)
+    KEEP (*(.text.*personality*))
+    /* .gnu.warning sections are handled specially by elf32.em.  */
+    *(.gnu.warning)
+  } :htext =0x90909090
+  .fini           :
+  {
+    KEEP (*(.fini))
+  } :htext =0x90909090
+  PROVIDE (__etext = .);
+  PROVIDE (_etext = .);
+  PROVIDE (etext = .);
+  .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) } :htext
+  .rodata1        : { *(.rodata1) } :htext
+  .eh_frame_hdr : { *(.eh_frame_hdr) } :htext :eh_frame_hdr
+  .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) } :htext
+  .gcc_except_table   : ONLY_IF_RO { KEEP (*(.gcc_except_table)) 
*(.gcc_except_table.*) } :htext
+  /* We don't maintain address congruence here, because saving
+   * hugepages is more important than saving executable size. */
+  . = ALIGN (0x1000000); /* Align to 16MB (4MB hugepage size, plus some slack 
in case of larger hugepages in future */
+  /* Exception handling  */
+  .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) } :data
+  .gcc_except_table   : ONLY_IF_RW { KEEP (*(.gcc_except_table)) 
*(.gcc_except_table.*) } :data
+  /* Thread Local Storage sections  */
+  .tdata         : { *(.tdata .tdata.* .gnu.linkonce.td.*) } :data
+  .tbss                  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } 
:data
+  /* Ensure the __preinit_array_start label is properly aligned.  We
+     could instead move the label definition inside the section, but
+     the linker would then create the section even if it turns out to
+     be empty, which isn't pretty.  */
+  . = ALIGN(64 / 8);
+  PROVIDE (__preinit_array_start = .);
+  .preinit_array     : { KEEP (*(.preinit_array)) } :data
+  PROVIDE (__preinit_array_end = .);
+  PROVIDE (__init_array_start = .);
+  .init_array     : { KEEP (*(.init_array)) } :data
+  PROVIDE (__init_array_end = .);
+  PROVIDE (__fini_array_start = .);
+  .fini_array     : { KEEP (*(.fini_array)) } :data
+  PROVIDE (__fini_array_end = .);
+  .ctors          :
+  {
+    /* gcc uses crtbegin.o to find the start of
+       the constructors, so we make sure it is
+       first.  Because this is a wildcard, it
+       doesn't matter if the user does not
+       actually link against crtbegin.o; the
+       linker won't look for a file to match a
+       wildcard.  The wildcard also means that it
+       doesn't matter which directory crtbegin.o
+       is in.  */
+    KEEP (*crtbegin*.o(.ctors))
+    /* We don't want to include the .ctor section from
+       from the crtend.o file until after the sorted ctors.
+       The .ctor section from the crtend file contains the
+       end of ctors marker and it must be last */
+    KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors))
+    KEEP (*(SORT(.ctors.*)))
+    KEEP (*(.ctors))
+  } :data
+  .dtors          :
+  {
+    KEEP (*crtbegin*.o(.dtors))
+    KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
+    KEEP (*(SORT(.dtors.*)))
+    KEEP (*(.dtors))
+  } :data
+  .jcr            : { KEEP (*(.jcr)) } :data
+  .data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro*) } :data
+  .dynamic        : { *(.dynamic) } :dynamic :data
+  .got            : { *(.got) } :data
+  .got.plt        : { *(.got.plt) } :data
+  .data           :
+  {
+    *(.data .data.* .gnu.linkonce.d.*)
+    KEEP (*(.gnu.linkonce.d.*personality*))
+    SORT(CONSTRUCTORS)
+  } :data
+  .data1          : { *(.data1) } :data
+  _edata = .;
+  PROVIDE (edata = .);
+  __bss_start = .;
+  .bss            :
+  {
+   *(.dynbss)
+   *(.bss .bss.* .gnu.linkonce.b.*)
+   *(COMMON)
+   /* Align here to ensure that the .bss section occupies space up to
+      _end.  Align after .bss to ensure correct alignment even if the
+      .bss section disappears because there are no input sections.  */
+   . = ALIGN(64 / 8);
+  } :data
+  . = ALIGN(64 / 8);
+  _end = .;
+  PROVIDE (end = .);
+  /* Stabs debugging sections.  */
+  .stab          0 : { *(.stab) }
+  .stabstr       0 : { *(.stabstr) }
+  .stab.excl     0 : { *(.stab.excl) }
+  .stab.exclstr  0 : { *(.stab.exclstr) }
+  .stab.index    0 : { *(.stab.index) }
+  .stab.indexstr 0 : { *(.stab.indexstr) }
+  .comment       0 : { *(.comment) }
+  /* DWARF debug sections.
+     Symbols in the DWARF debugging sections are relative to the beginning
+     of the section so we begin them at 0.  */
+  /* DWARF 1 */
+  .debug          0 : { *(.debug) }
+  .line           0 : { *(.line) }
+  /* GNU DWARF 1 extensions */
+  .debug_srcinfo  0 : { *(.debug_srcinfo) }
+  .debug_sfnames  0 : { *(.debug_sfnames) }
+  /* DWARF 1.1 and DWARF 2 */
+  .debug_aranges  0 : { *(.debug_aranges) }
+  .debug_pubnames 0 : { *(.debug_pubnames) }
+  /* DWARF 2 */
+  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
+  .debug_abbrev   0 : { *(.debug_abbrev) }
+  .debug_line     0 : { *(.debug_line) }
+  .debug_frame    0 : { *(.debug_frame) }
+  .debug_str      0 : { *(.debug_str) }
+  .debug_loc      0 : { *(.debug_loc) }
+  .debug_macinfo  0 : { *(.debug_macinfo) }
+  /* SGI/MIPS DWARF 2 extensions */
+  .debug_weaknames 0 : { *(.debug_weaknames) }
+  .debug_funcnames 0 : { *(.debug_funcnames) }
+  .debug_typenames 0 : { *(.debug_typenames) }
+  .debug_varnames  0 : { *(.debug_varnames) }
+  /DISCARD/ : { *(.note.GNU-stack) }
+}
diff --git a/tests/Makefile b/tests/Makefile
index 7d67486..fcb8b2a 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -27,11 +27,11 @@ INSTALL = install
 TESTS = $(LIB_TESTS) $(NOLIB_TESTS) $(STRESS_TESTS)
 ifdef ELF32
 TESTS += $(LDSCRIPT_TESTS) $(HUGELINK_TESTS) $(HUGELINK_TESTS:%=xB.%) \
-       $(HUGELINK_TESTS:%=xBDT.%)
+       $(HUGELINK_TESTS:%=xBDT.%) $(HUGELINK_TESTS:%=xT.%)
 else
 ifdef ELF64
 TESTS += $(LDSCRIPT_TESTS) $(HUGELINK_TESTS) $(HUGELINK_TESTS:%=xB.%) \
-       $(HUGELINK_TESTS:%=xBDT.%)
+       $(HUGELINK_TESTS:%=xBDT.%) $(HUGELINK_TESTS:%=xT.%)
 endif
 endif
 
@@ -138,6 +138,18 @@ obj64/xBDT.%: $(SCRIPTS64).xBDT $(HUGETLBFS_LD) obj64/%.o 
obj64/testutils.o
        @ln -sf ../$(HUGETLBFS_LD) obj64/ld
        $(CC64) -B./obj64 $(LDFLAGS) $(LDFLAGS64) -o $@ $(LDLIBS) 
-Wl,--hugetlbfs-link=BDT $(filter %.o,$^)
 
+obj32/xT.%: $(SCRIPTS32).xT $(HUGETLBFS_LD) obj32/%.o obj32/testutils.o
+       @$(VECHO) LD32 "(xT test)" $@
+       @mkdir -p obj32
+       @ln -sf ../$(HUGETLBFS_LD) obj32/ld
+       $(CC32) -B./obj32 $(LDFLAGS) $(LDFLAGS32) -o $@ $(LDLIBS) 
-Wl,--hugetlbfs-link=T $(filter %.o,$^)
+
+obj64/xT.%: $(SCRIPTS64).xT $(HUGETLBFS_LD) obj64/%.o obj64/testutils.o
+       @$(VECHO) LD64 "(xT test)" $@
+       @mkdir -p obj64
+       @ln -sf ../$(HUGETLBFS_LD) obj64/ld
+       $(CC64) -B./obj64 $(LDFLAGS) $(LDFLAGS64) -o $@ $(LDLIBS) 
-Wl,--hugetlbfs-link=T $(filter %.o,$^)
+
 $(HELPERS:%=obj32/%): %: %.o
        @$(VECHO) LD32 "(helper)" $@
        $(CC32) $(LDFLAGS) $(LDFLAGS32) -o $@ $^ $(LDLIBS) -lhugetlbfs 
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 8f1e7ac..2d14fef 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -66,12 +66,15 @@ elflink_test () {
     preload_test "$@" "$baseprog"
     run_test "$@" "xB.$baseprog"
     run_test "$@" "xBDT.$baseprog"
+    run_test "$@" "xT.$baseprog"
     # Test we don't blow up if HUGETLB_MINIMAL_COPY is diabled
     run_test HUGETLB_MINIMAL_COPY=no "$@" "xB.$baseprog"
     run_test HUGETLB_MINIMAL_COPY=no "$@" "xBDT.$baseprog"
+    run_test HUGETLB_MINIMAL_COPY=no "$@" "xT.$baseprog"
     # Test that HUGETLB_ELFMAP=no inhibits remapping as intended
     run_test HUGETLB_ELFMAP=no "$@" "xB.$baseprog"
     run_test HUGETLB_ELFMAP=no "$@" "xBDT.$baseprog"
+    run_test HUGETLB_ELFMAP=no "$@" "xT.$baseprog"
 }
 
 elfshare_test () {
@@ -88,8 +91,11 @@ elfshare_test () {
     clear_hpages
     run_test HUGETLB_SHARE=1 "$@" "xBDT.$baseprog"
     clear_hpages
+    run_test HUGETLB_SHARE=1 "$@" "xT.$baseprog"
+    clear_hpages
     run_test HUGETLB_SHARE=1 "$@" "xB.$baseprog"
     run_test HUGETLB_SHARE=1 "$@" "xBDT.$baseprog"
+    run_test HUGETLB_SHARE=1 "$@" "xT.$baseprog"
     clear_hpages
 }
 
-- 
Nishanth Aravamudan <[EMAIL PROTECTED]>
IBM Linux Technology Center

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to