ppc: rework plt detection
We currently emit LONG(0) into the .plt section of relinked ppc binaries
to make it appear in the filesz (on-disk) portion of the data/bss
segment. This is a problem, however, for powerpc64, where the ABI
specifies that the .plt section is NOBITS (x86 and x86_64 mark the .plt
PROGBITS). Given that the program is being relinked to begin with,
however, it seems logical to simply add a tag, similar to
__executable_start, to make finding the "libhuge" filesz easy to find.
Do exactly this, via __libhuge_filesz, and skip the extracopy detection
if this symbol is defined. Tested on powerpc64.
Signed-off-by: Nishanth Aravamudan <[EMAIL PROTECTED]>
diff --git a/elflink.c b/elflink.c
index 5058248..00b403a 100644
--- a/elflink.c
+++ b/elflink.c
@@ -414,6 +414,7 @@ static void get_extracopy(struct seg_info *seg, Elf_Phdr
*phdr, int phnum)
int ret, numsyms, found_sym = 0;
void *start, *end, *start_orig, *end_orig;
void *sym_start, *sym_end;
+ extern void __libhuge_filesz __attribute__((weak));
end_orig = seg->vaddr + seg->memsz;
start_orig = seg->vaddr + seg->filesz;
@@ -422,6 +423,13 @@ static void get_extracopy(struct seg_info *seg, Elf_Phdr
*phdr, int phnum)
if (!minimal_copy)
goto bail2;
+ if (&__libhuge_filesz) {
+ found_sym = 1;
+ start = start_orig;
+ end = &__libhuge_filesz;
+ goto found;
+ }
+
/* Find dynamic program header */
ret = find_dynamic(&dyntab, phdr, phnum);
if (ret < 0)
@@ -462,6 +470,7 @@ static void get_extracopy(struct seg_info *seg, Elf_Phdr
*phdr, int phnum)
if (__debug)
check_bss(end, end_orig);
+found:
if (found_sym) {
/* Return the copy window */
seg->extra_vaddr = start;
diff --git a/ldscripts/elf32ppclinux.xBDT b/ldscripts/elf32ppclinux.xBDT
index f30bd3b..2dd8e8f 100644
--- a/ldscripts/elf32ppclinux.xBDT
+++ b/ldscripts/elf32ppclinux.xBDT
@@ -163,7 +163,8 @@ SECTIONS
/* . = DATA_SEGMENT_RELRO_END (0, .); */
/* Ensure the plt appears in the on-disk portion of the binary so it
* will be copied during hugetlb remapping */
- .plt : { *(.plt) LONG(0) } :hdata
+ .plt : { *(.plt) } :hdata
+ __libhuge_filesz = .;
.data :
{
*(.data .data.* .gnu.linkonce.d.*)
diff --git a/ldscripts/elf64ppc.xBDT b/ldscripts/elf64ppc.xBDT
index 68abf09..4e2f163 100644
--- a/ldscripts/elf64ppc.xBDT
+++ b/ldscripts/elf64ppc.xBDT
@@ -181,7 +181,8 @@ SECTIONS
} :hdata
/* Ensure the plt appears in the on-disk portion of the binary so it
* will be copied during hugetlb remapping */
- .plt : { LONG(0) *(.plt) } :hdata
+ .plt : { *(.plt) } :hdata
+ __libhuge_filesz = .;
.bss :
{
*(.dynbss)
--
Nishanth Aravamudan <[EMAIL PROTECTED]>
IBM Linux Technology Center
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Libhugetlbfs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel