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

document the usage of pkg-config --libs libselinux on Linux #67

Open
gogo2464 opened this issue Oct 5, 2023 · 2 comments
Open

document the usage of pkg-config --libs libselinux on Linux #67

gogo2464 opened this issue Oct 5, 2023 · 2 comments
Assignees
Labels
binary fails DDisasm fails to correctly disassemble a binary

Comments

@gogo2464
Copy link
Contributor

gogo2464 commented Oct 5, 2023

I used to take so much time to find the good linker to my reversed application when suddenly I found the command pkg-config --libs "libselinux" that in accordance with ldd "$(which ls)" could find the right library linkage from the ldd command.

example:

$ ldd "$(which ls)"
	linux-vdso.so.1 (0x00007ffd1258c000)
	libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f51a542c000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f51a5258000)
	libpcre2-8.so.0 => /lib/x86_64-linux-gnu/libpcre2-8.so.0 (0x00007f51a51c0000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f51a51ba000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f51a54ae000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f51a5198000)
$ pkg-config --libs "libselinux"
-lselinux

$ apt-cache search selinux
selinux-utils
libselinux1-dev
...

sudo apt install --yes selinux-utils libselinux1-dev

$ gcc -nostartfiles ls.s  -o ls-out -l selinux

I suggest to add this trick to the doc.

Assign me to this issue please :)

Best regards.

@gogo2464 gogo2464 added the binary fails DDisasm fails to correctly disassemble a binary label Oct 5, 2023
@aeflores
Copy link
Collaborator

aeflores commented Oct 5, 2023

We typically recommend using gtirb-pprinter --binary to reassemble (it will create the compilation command with the necessary library dependencies). Have you had problems with that approach?

gtirb-pprinter ls.gtirb --binary ls-out

Also, if you already have the libraries from ldd, you can link them directly, right?

gcc -nostartfiles ls.s  -o ls-out -l:libselinux.so.1

@gogo2464
Copy link
Contributor Author

gogo2464 commented Oct 5, 2023

I prefer to use a Makefile. Do you think people could enjoy this improvement? Seems more portable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
binary fails DDisasm fails to correctly disassemble a binary
Projects
None yet
Development

No branches or pull requests

2 participants