Skip to content

Explicitly link with -no-pie#9

Open
paulmenzel wants to merge 1 commit intoxoreaxeaxeax:masterfrom
paulmenzel:build-with-no-pie
Open

Explicitly link with -no-pie#9
paulmenzel wants to merge 1 commit intoxoreaxeaxeax:masterfrom
paulmenzel:build-with-no-pie

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…


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.

3 participants