aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric B Munson <ebmunson@us.ibm.com>2008-05-06 11:48:39 -0700
committerNishanth Aravamudan <nacc@us.ibm.com>2008-05-07 09:17:16 -0700
commit8e9bb0423d71f7816e95734c692cd6251f069518 (patch)
treef0d3d191191f4b0ea8ff61ccc5dac47d7d039c58
parent7e7b88643420becef7338f850b7bb3d0afe974d6 (diff)
downloadlibhugetlbfs-8e9bb0423d71f7816e95734c692cd6251f069518.tar.gz
Add plt_extrasz for PPC32
Currently segment remapping on powerpc32 fails to copy the PLT section. This is because, like ppc64, the PLT is NOBITS so it is missed by the PROGBITS copy. This patch adds the elf32ppclinux.c file that defines the plt_extrasz function to compute the PLT size to ensure that it is copied. The only difference from the 64 bit version is the size of PLT[0] is 72 bytes on PPC32 as opposed to 24 bytes on PPC64. Signed-off-by: Eric Munson <ebmunson@us.ibm.com> Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
-rw-r--r--Makefile3
-rw-r--r--elf32ppclinux.c52
2 files changed, 55 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 6d5b328..dfc069f 100644
--- a/Makefile
+++ b/Makefile
@@ -80,6 +80,9 @@ endif
ifdef ELF64
LIBOBJS64 = obj64/elflink.o obj64/sys-$(ELF64).o
endif
+ifeq ($(ELF32),elf32ppclinux)
+LIBOBJS32 += obj32/$(ELF32).o
+endif
ifeq ($(ELF64),elf64ppc)
LIBOBJS64 += obj64/$(ELF64).o
endif
diff --git a/elf32ppclinux.c b/elf32ppclinux.c
new file mode 100644
index 0000000..eb54411
--- /dev/null
+++ b/elf32ppclinux.c
@@ -0,0 +1,52 @@
+/*
+ * libhugetlbfs - Easy use of Linux hugepages
+ * Copyright (C) 2008 Adam Litke, IBM Corporation.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <elf.h>
+#include <link.h>
+
+/*
+ * The powerpc 32-bit ELF ABI defines the location and size of the plt as
+ * follows (see the ELF ABI and powerpc32 supplement for details):
+ *
+ * Location: (data segment p_vaddr) + (data segment p_filesz)
+ * Size: (dynamic symbol table DT_PTRELSZ entry) + 72
+ *
+ * plt entries have likely been initialized when the libhugetlbfs remapping
+ * code runs, we must copy these entries when preparing the data segment. Tell
+ * the arch-independent code how many bytes to copy.
+ */
+ElfW(Word) plt_extrasz(ElfW(Dyn) *dyntab)
+{
+ int i;
+ ElfW(Word) pltrelsz = 0;
+
+ /* Find the needed information in the dynamic section */
+ for (i = 0; dyntab[i].d_tag != DT_NULL; i++)
+ if (dyntab[i].d_tag == DT_PLTRELSZ)
+ pltrelsz = dyntab[i].d_un.d_val;
+
+ /* pltrelsz indicates the size of all plt entries used to cache
+ * symbol lookups, but does not include the reserved entry at PLT[0].
+ * 72 bytes is the ABI-defined size of a plt entry.
+ */
+ if (pltrelsz)
+ return pltrelsz + 72;
+ else
+ return 0;
+}