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

Explicitly link with -no-pie #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

paulmenzel
Copy link

Tested on Debian Sid/unstable with Debian’s package
libcapstone-dev 3.0.4-1 installed.

If libcapstone.a is not build with `-fPIC`, building `injector` fails
with the error below.

```
/usr/bin/ld: injector.o: relocation R_X86_64_32S against undefined symbol `dummy_stack' can not be used when making a shared object; recompile with -fPIC
```

So explicitly link the binary as a position dependent executable by
passing `-no-pie` [1].

This probably needs to be made configurable, or the build system needs
to detect how `libcapstone.a` is built.

[1] https://wiki.ubuntu.com/SecurityTeam/PIE

Fixes: xoreaxeaxeax#2, xoreaxeaxeax#5
@paulmenzel
Copy link
Author

Trying to run the Python script afterward results in the error below. No idea if it’s related to the Debian platform or this change.

$ sudo ./sifter.py --unk --dis --len --sync --tick -- -P1 -t
Traceback (most recent call last):
  File "./sifter.py", line 842, in <module>
    main()
  File "./sifter.py", line 817, in main
    arch = re.search(r".*(..)-bit.*", injector_bitness).group(1)
AttributeError: 'NoneType' object has no attribute 'group'

Copy link

@igalic igalic left a comment

Choose a reason for hiding this comment

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

this could probably be simplified…

@@ -32,7 +32,7 @@
all: injector

injector: injector.o
$(CC) $(CFLAGS) $< -O3 -Wall -l:libcapstone.a -o $@ -pthread
$(CC) $(CFLAGS) $< -O3 -Wall -no-pie -l:libcapstone.a -o $@ -pthread
Copy link

Choose a reason for hiding this comment

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

why not just add $(LDFLAGS) here?

@Pr0methean
Copy link

Fixes #2, #5, #40, #64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants