Skip to content

Commit

Permalink
Merge 914043a into 67d49a6
Browse files Browse the repository at this point in the history
  • Loading branch information
clubby789 committed Nov 28, 2022
2 parents 67d49a6 + 914043a commit ea42785
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
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
18 changes: 17 additions & 1 deletion pwnlib/asm.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,21 @@ def _linker():
'i386': ['-m', 'elf_i386'],
}.get(context.arch, [])

try:
with context.local(log_level='critical'):
version = _run(ld + ["-v"])
if "GNU ld (GNU Binutils)" in version:
number = version.split()[4]
major, minor, _ = [int(n) for n in number.split(".")]
# https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob_plain;f=ld/NEWS;hb=refs/heads/binutils-2_39-branch
# GNU ld 2.39+ will warn on RWX segments in an ELF
if (major == 2 and minor >= 39) or major > 2:
arguments.append("--no-warn-rwx-segments")
except Exception:
# If the output format is wrong or `ld -v` errors, just ignore it
# and (maybe) fail later
pass

return ld + bfd + [E] + arguments

def _objcopy():
Expand Down Expand Up @@ -570,7 +585,8 @@ def make_elf(data,
log.error("Cannot specify a VMA for a shared library.")

if context.arch == 'thumb':
to_thumb = asm(shellcraft.arm.to_thumb(), arch='arm')
with context.local(arch='arm'):
to_thumb = asm(shellcraft.arm.to_thumb())

if not data.startswith(to_thumb):
data = to_thumb + data
Expand Down

0 comments on commit ea42785

Please sign in to comment.