summaryrefslogtreecommitdiff
path: root/debian
diff options
context:
space:
mode:
authorFelipe Sateler <fsateler@debian.org>2015-11-12 20:25:58 -0300
committerFelipe Sateler <fsateler@debian.org>2015-11-12 20:25:58 -0300
commit4a9639cf6c379461bed5040c58253d795f36ef23 (patch)
tree5cda77d68aef92a4ad029f0d8064d3b2dab93c5b /debian
parent58ef8851c9903562e2619f388ae2f18f352de757 (diff)
Pick upstream commit to use a dynamic page size. Fixes FTBFS on ppc64el. Closes: #799880
Diffstat (limited to 'debian')
-rw-r--r--debian/changelog7
-rw-r--r--debian/patches/0003-Configure-automatically-the-page-size-with-a-runtime.patch169
-rw-r--r--debian/patches/series1
3 files changed, 177 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog
index 26ddf00..2594e14 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+patchelf (0.8-3) UNRELEASED; urgency=medium
+
+ * Pick upstream commit to use a dynamic page size. Fixes FTBFS on ppc64el.
+ Closes: #799880
+
+ -- Felipe Sateler <fsateler@debian.org> Thu, 12 Nov 2015 20:25:01 -0300
+
patchelf (0.8-2) unstable; urgency=medium
* Document --remove-needed in manpage
diff --git a/debian/patches/0003-Configure-automatically-the-page-size-with-a-runtime.patch b/debian/patches/0003-Configure-automatically-the-page-size-with-a-runtime.patch
new file mode 100644
index 0000000..0f5a899
--- /dev/null
+++ b/debian/patches/0003-Configure-automatically-the-page-size-with-a-runtime.patch
@@ -0,0 +1,169 @@
+From: Adrien Devresse <adrien.devresse@epfl.ch>
+Date: Mon, 20 Jul 2015 16:00:51 +0200
+Subject: Configure automatically the page size with a runtime call,
+ solve the issue #53 related to prtability on powerpc64 architecture
+
+---
+ configure.ac | 10 ++++++++++
+ src/patchelf.cc | 48 +++++++++++++++++++++++++++---------------------
+ 2 files changed, 37 insertions(+), 21 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index bdda1a6..8de874f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -6,5 +6,15 @@ AM_INIT_AUTOMAKE([-Wall -Werror dist-bzip2 foreign color-tests parallel-tests])
+ AM_PROG_CC_C_O
+ AC_PROG_CXX
+
++AC_CHECK_HEADERS([attr/libattr.h attr/error_context.h])
++AC_SEARCH_LIBS(attr_copy_file, attr)
++AC_CHECK_FUNCS([attr_copy_file])
++
++AC_CHECK_HEADERS([sys/acl.h acl/libacl.h])
++AC_SEARCH_LIBS(perm_copy_file, acl)
++AC_CHECK_FUNCS([perm_copy_file])
++
++AC_CHECK_FUNCS([sysconf])
++
+ AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile patchelf.spec])
+ AC_OUTPUT
+diff --git a/src/patchelf.cc b/src/patchelf.cc
+index 2c6bec7..2c9da0d 100644
+--- a/src/patchelf.cc
++++ b/src/patchelf.cc
+@@ -22,12 +22,6 @@
+ using namespace std;
+
+
+-#ifdef MIPSEL
+-/* The lemote fuloong 2f kernel defconfig sets a page size of 16KB */
+-const unsigned int pageSize = 4096*4;
+-#else
+-const unsigned int pageSize = 4096;
+-#endif
+
+
+ static bool debugMode = false;
+@@ -45,6 +39,16 @@ unsigned char * contents = 0;
+ #define ElfFileParamNames Elf_Ehdr, Elf_Phdr, Elf_Shdr, Elf_Addr, Elf_Off, Elf_Dyn, Elf_Sym
+
+
++static unsigned int getPageSize(){
++#if (defined HAVE_SYSCONF)
++ // if present, use sysconf to get kernel page size
++ return sysconf(_SC_PAGESIZE);
++#else
++ return 4096;
++#endif
++}
++
++
+ template<ElfFileParams>
+ class ElfFile
+ {
+@@ -388,9 +392,9 @@ void ElfFile<ElfFileParamNames>::shiftFile(unsigned int extraPages, Elf_Addr sta
+ /* Move the entire contents of the file `extraPages' pages
+ further. */
+ unsigned int oldSize = fileSize;
+- unsigned int shift = extraPages * pageSize;
+- growFile(fileSize + extraPages * pageSize);
+- memmove(contents + extraPages * pageSize, contents, oldSize);
++ unsigned int shift = extraPages * getPageSize();
++ growFile(fileSize + extraPages * getPageSize());
++ memmove(contents + extraPages * getPageSize(), contents, oldSize);
+ memset(contents + sizeof(Elf_Ehdr), 0, shift - sizeof(Elf_Ehdr));
+
+ /* Adjust the ELF header. */
+@@ -407,8 +411,8 @@ void ElfFile<ElfFileParamNames>::shiftFile(unsigned int extraPages, Elf_Addr sta
+ if (rdi(phdrs[i].p_align) != 0 &&
+ (rdi(phdrs[i].p_vaddr) - rdi(phdrs[i].p_offset)) % rdi(phdrs[i].p_align) != 0) {
+ debug("changing alignment of program header %d from %d to %d\n", i,
+- rdi(phdrs[i].p_align), pageSize);
+- wri(phdrs[i].p_align, pageSize);
++ rdi(phdrs[i].p_align), getPageSize());
++ wri(phdrs[i].p_align, getPageSize());
+ }
+ }
+
+@@ -422,7 +426,7 @@ void ElfFile<ElfFileParamNames>::shiftFile(unsigned int extraPages, Elf_Addr sta
+ wri(phdr.p_vaddr, wri(phdr.p_paddr, startPage));
+ wri(phdr.p_filesz, wri(phdr.p_memsz, shift));
+ wri(phdr.p_flags, PF_R | PF_W);
+- wri(phdr.p_align, pageSize);
++ wri(phdr.p_align, getPageSize());
+ }
+
+
+@@ -551,7 +555,7 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsLibrary()
+ page of other segments. */
+ Elf_Addr startPage = 0;
+ for (unsigned int i = 0; i < phdrs.size(); ++i) {
+- Elf_Addr thisPage = roundUp(rdi(phdrs[i].p_vaddr) + rdi(phdrs[i].p_memsz), pageSize);
++ Elf_Addr thisPage = roundUp(rdi(phdrs[i].p_vaddr) + rdi(phdrs[i].p_memsz), getPageSize());
+ if (thisPage > startPage) startPage = thisPage;
+ }
+
+@@ -567,7 +571,7 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsLibrary()
+ debug("needed space is %d\n", neededSpace);
+
+
+- size_t startOffset = roundUp(fileSize, pageSize);
++ size_t startOffset = roundUp(fileSize, getPageSize());
+
+ growFile(startOffset + neededSpace);
+
+@@ -591,7 +595,7 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsLibrary()
+ size_t hole = startPage - startOffset;
+ /* Print a warning, because the hole could be very big. */
+ fprintf(stderr, "warning: working around a Linux kernel bug by creating a hole of %zu bytes in ā€˜%sā€™\n", hole, fileName.c_str());
+- assert(hole % pageSize == 0);
++ assert(hole % getPageSize() == 0);
+ /* !!! We could create an actual hole in the file here,
+ but it's probably not worth the effort. */
+ growFile(fileSize + hole);
+@@ -611,7 +615,7 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsLibrary()
+ wri(phdr.p_vaddr, wri(phdr.p_paddr, startPage));
+ wri(phdr.p_filesz, wri(phdr.p_memsz, neededSpace));
+ wri(phdr.p_flags, PF_R | PF_W);
+- wri(phdr.p_align, pageSize);
++ wri(phdr.p_align, getPageSize());
+
+
+ /* Write out the replaced sections. */
+@@ -682,7 +686,7 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsExecutable()
+ debug("first reserved offset/addr is 0x%x/0x%llx\n",
+ startOffset, (unsigned long long) startAddr);
+
+- assert(startAddr % pageSize == startOffset % pageSize);
++ assert(startAddr % getPageSize() == startOffset % getPageSize());
+ Elf_Addr firstPage = startAddr - startOffset;
+ debug("first page is 0x%llx\n", (unsigned long long) firstPage);
+
+@@ -711,13 +715,13 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsExecutable()
+ neededSpace += sizeof(Elf_Phdr);
+ debug("needed space is %d\n", neededSpace);
+
+- unsigned int neededPages = roundUp(neededSpace - startOffset, pageSize) / pageSize;
++ unsigned int neededPages = roundUp(neededSpace - startOffset, getPageSize()) / getPageSize();
+ debug("needed pages is %d\n", neededPages);
+- if (neededPages * pageSize > firstPage)
++ if (neededPages * getPageSize() > firstPage)
+ error("virtual address space underrun!");
+
+- firstPage -= neededPages * pageSize;
+- startOffset += neededPages * pageSize;
++ firstPage -= neededPages * getPageSize();
++ startOffset += neededPages * getPageSize();
+
+ shiftFile(neededPages, firstPage);
+ }
+@@ -1132,6 +1136,8 @@ static void patchElf()
+ if (!printInterpreter && !printRPath)
+ debug("patching ELF file `%s'\n", fileName.c_str());
+
++ debug("Kernel page size is %u bytes\n", getPageSize());
++
+ mode_t fileMode;
+
+ readFile(fileName, &fileMode);
diff --git a/debian/patches/series b/debian/patches/series
index ef96ada..b276194 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
0001-Document-remove-needed-in-manpage.patch
0002-Fix-typo-in-manpage.patch
+0003-Configure-automatically-the-page-size-with-a-runtime.patch