Skip to content

Tests fail on PIC executables: maximum file size exceeded #47

Closed

Description

@ppisar

Fedora Linux distribution started to build all executables as position-independent code.

patchelf fails selftest on such executables (see the 'maximum file size exceeded'):

$  ../src/patchelf --set-interpreter /oops scratch/set-interpreter-short/simple
warning: working around a Linux kernel bug by creating a hole of 18870272 bytes in ‘scratch/set-interpreter-short/simple’
maximum file size exceeded

The reproducer is to call configure as:

$ ./configure CFLAGS='-O0 -fPIE' LDFLAGS='-specs=/usr/lib/rpm/redhat/redhat-hardened-ld' CXXFLAGS='-O0 -fPIE'

The /usr/lib/rpm/redhat/redhat-hardened-ld contains:

*self_spec:
+ %{!shared:%{!r:-pie}}

*link:
+ -z now

Alternatively you can replace LDFLAGS with '-z now' and add '-pie' to LDFLAGS_local variable in tests/Makefile.am (and run autoreconf before ./configure).

Complete test suite results are:

PASS: plain-fail.sh
PASS: plain-run.sh
PASS: shrink-rpath.sh
FAIL: set-interpreter-short.sh
FAIL: set-interpreter-long.sh
FAIL: set-rpath.sh
PASS: no-rpath.sh
FAIL: big-dynstr.sh
FAIL: set-rpath-library.sh
PASS: soname.sh
PASS: no-rpath-amd64.sh
PASS: no-rpath-armel.sh
PASS: no-rpath-armhf.sh
PASS: no-rpath-hurd-i386.sh
PASS: no-rpath-i386.sh
XFAIL: no-rpath-ia64.sh
PASS: no-rpath-kfreebsd-amd64.sh
PASS: no-rpath-kfreebsd-i386.sh
PASS: no-rpath-mips.sh
PASS: no-rpath-mipsel.sh
PASS: no-rpath-powerpc.sh
PASS: no-rpath-s390.sh
PASS: no-rpath-sh4.sh
PASS: no-rpath-sparc.sh

Activity

  1. ppisar commented on Jul 7, 2015

    @ppisar
    Author
  2. ppisar commented on Jul 7, 2015

    @ppisar
    Author

    The issue is that maxSize is set to fileSize + 8 MB, the output buffer is allocated to the maxSize, then a hole is detected. But the hole is bigger than 8 MB, thus the growFile() aborts.

    Either the 8 MB constant should be raised to bigger arbitrary constant, or the output buffer and the maxSize should be enlarged by the hole, or the detected hole is bogus in case of PIE executables.

  3. added a commit that references this issue on Jul 10, 2015
  4. ppisar commented on Jul 13, 2015

    @ppisar
    Author
  5. added a commit that references this issue on Sep 14, 2016
  6. added a commit that references this issue on Sep 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions