Skip to content

[dyld] Do not resolve symbols from executables compiled with -fPIE. #9404

Merged
vgvassilev merged 3 commits intoroot-project:masterfrom
vgvassilev:fix-7366
Jan 7, 2022
Merged

[dyld] Do not resolve symbols from executables compiled with -fPIE. #9404
vgvassilev merged 3 commits intoroot-project:masterfrom
vgvassilev:fix-7366

Conversation

@vgvassilev
Copy link
Copy Markdown
Member

@vgvassilev vgvassilev commented Dec 9, 2021

Executables that are compiled with fPIE means they are compiled in a position independent manner and are almost indistinguishable from the shared objects. A reasonably reliable way to find if this was a pie executable is to check the DF_1_PIE in the dynamic section of ELF.

The pseudo-code is:

    if DT_FLAGS_1 dynamic section entry is present
      if DF_1_PIE is set in DT_FLAGS_1:
        print pie executable
      else
        print shared object
See https://stackoverflow.com/questions/34519521/why-does-gcc-create-a-shared-object-instead-of-an-executable-binary-according-to/34522357#34522357

Fixes #7366

Patch by Alexander Penev (@alexander-penev)

@phsft-bot
Copy link
Copy Markdown

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu2004/soversion, mac1015/python3, mac11/cxx17, windows10/cxx14
How to customize builds

@phsft-bot
Copy link
Copy Markdown

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu2004/soversion, mac1015/python3, mac11/cxx17, windows10/cxx14
How to customize builds

@phsft-bot
Copy link
Copy Markdown

Build failed on ROOT-performance-centos8-multicore/default.
Running on olbdw-01.cern.ch:/data/sftnight/workspace/root-pullrequests-build
See console output.

Failing tests:

@phsft-bot
Copy link
Copy Markdown

Build failed on mac11/cxx17.
Running on macphsft23.dyndns.cern.ch:/Users/sftnight/build/workspace/root-pullrequests-build
See console output.

Warnings:

  • [2021-12-09T19:45:28.905Z] /Users/sftnight/build/workspace/root-pullrequests-build/root/interpreter/cling/lib/Interpreter/DynamicLibraryManagerSymbol.cpp:757:33: warning: variable 'isPIEExecutable' may be uninitialized when used here [-Wconditional-uninitialized]

@phsft-bot
Copy link
Copy Markdown

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu2004/soversion, mac1015/python3, mac11/cxx17, windows10/cxx14
How to customize builds

@Axel-Naumann
Copy link
Copy Markdown
Member

Any chance to have a test?

@Axel-Naumann
Copy link
Copy Markdown
Member

And: congrats for solving this!

@phsft-bot
Copy link
Copy Markdown

Build failed on mac11/cxx17.
Running on macphsft20.dyndns.cern.ch:/Users/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

Executables that are compiled with fPIE means they are compiled in a position
independent manner and are almost indistinguishable from the shared objects. A
reasonably reliable way to find if this was a `pie executable` is to check the
`DF_1_PIE` in the dynamic section of ELF.

The pseudo-code is:
```
if DT_FLAGS_1 dynamic section entry is present
  if DF_1_PIE is set in DT_FLAGS_1:
    print pie executable
  else
    print shared object
```

See https://stackoverflow.com/questions/34519521/why-does-gcc-create-a-shared-object-instead-of-an-executable-binary-according-to/34522357#34522357

Fixes root-project#7366

Patch by Alexander Penev (@alexander-penev)
@phsft-bot
Copy link
Copy Markdown

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu2004/soversion, mac1015/python3, mac11/cxx17, windows10/cxx14
How to customize builds

@vgvassilev
Copy link
Copy Markdown
Member Author

@Axel-Naumann ping.

Copy link
Copy Markdown
Member

@Axel-Naumann Axel-Naumann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late review - LGTM, thanks! (and see missing newline at EOF)


int main() {
return 0;
} No newline at end of file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newline at EOF?

Suggested change
}
}

@vgvassilev vgvassilev merged commit 1251936 into root-project:master Jan 7, 2022
@vgvassilev vgvassilev deleted the fix-7366 branch January 7, 2022 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ACLiC compilation confuses compiled binaries with shared objects, breaking compilation in some cases

4 participants