Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix make_elf on systems with GNU ld 2.39+ #2141

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,15 @@ The table below shows which release corresponds to each branch, and what date th
- [#1981][1981] Fix `cyclic_find()` to make it work with large int values
- [#2123][2123] Fix ROP without a writeable cache directory
- [#2124][2124] Fix `tube.recvpred()` timout argument
- [#2141][2141] Fix `make_elf` on systems with GNU ld 2.39+

[1922]: https://github.com/Gallopsled/pwntools/pull/1922
[1828]: https://github.com/Gallopsled/pwntools/pull/1828
[1939]: https://github.com/Gallopsled/pwntools/pull/1939
[1981]: https://github.com/Gallopsled/pwntools/pull/1981
[2123]: https://github.com/Gallopsled/pwntools/pull/2123
[2124]: https://github.com/Gallopsled/pwntools/pull/2124
[2141]: https://github.com/Gallopsled/pwntools/pull/2141

## 4.7.1

Expand Down
10 changes: 10 additions & 0 deletions pwnlib/asm.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,16 @@ def _linker():
'i386': ['-m', 'elf_i386'],
}.get(context.arch, [])

try:
# Test if this argument is recognised
# If so, we should add it to the commandline so we don't throw spurious errors later on
# https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob_plain;f=ld/NEWS;hb=refs/heads/binutils-2_39-branch
proc = subprocess.run(ld + ["--no-warn-rwx-segments", "--help"], capture_output=True)
if proc.returncode == 0:
arguments.append("--no-warn-rwx-segments")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please see the recommendation in #2140

except Exception as e:
pass

return ld + bfd + [E] + arguments

def _objcopy():
Expand Down