Skip to content

Instantly share code, notes, and snippets.

@thejh
Created February 24, 2020 23:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thejh/38cbe890f83975640a823b3278ade2f6 to your computer and use it in GitHub Desktop.
Save thejh/38cbe890f83975640a823b3278ade2f6 to your computer and use it in GitHub Desktop.
poppler pdftoppm syscalls
~/tmp/pdf$ cat localtime_hack.c
#include <time.h>
__attribute__((constructor)) static void localtime_hack(void) {
time_t t = {0};
localtime(&t);
}
~/tmp/pdf$ gcc -shared -fPIC -o localtime_hack.so localtime_hack.c
~/tmp/pdf$ LD_BIND_NOW=1 LD_PRELOAD=./localtime_hack.so strace -f -e trace='!write,pread64,brk' pdftoppm test.pdf test.png 2>&1 | grep -A10000000 'open.*test\.pdf'
openat(AT_FDCWD, "test.pdf", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0600, st_size=127040, ...}) = 0
lseek(3, 0, SEEK_END) = 127040
lseek(3, 0, SEEK_END) = 127040
lseek(3, 0, SEEK_END) = 127040
openat(AT_FDCWD, "/usr/share/poppler/ColorProfiles/display.icc", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/poppler/ColorProfiles/RGB.icc", O_RDONLY) = -1 ENOENT (No such file or directory)
mmap(NULL, 6320128, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa42ae38000
mmap(NULL, 2105344, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa42ac36000
mmap(NULL, 159744, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa42c334000
munmap(0x7fa42c334000, 159744) = 0
mmap(NULL, 2105344, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa42aa34000
munmap(0x7fa42aa34000, 2105344) = 0
mmap(NULL, 5328896, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa42a721000
munmap(0x7fa42a721000, 5328896) = 0
openat(AT_FDCWD, "test.png-01.ppm", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
close(4) = 0
openat(AT_FDCWD, "test.png-02.ppm", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
close(4) = 0
openat(AT_FDCWD, "test.png-03.ppm", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
close(4) = 0
openat(AT_FDCWD, "test.png-04.ppm", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
close(4) = 0
openat(AT_FDCWD, "test.png-05.ppm", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
close(4) = 0
openat(AT_FDCWD, "test.png-06.ppm", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
close(4) = 0
openat(AT_FDCWD, "test.png-07.ppm", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
close(4) = 0
openat(AT_FDCWD, "test.png-08.ppm", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
close(4) = 0
openat(AT_FDCWD, "test.png-09.ppm", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
close(4) = 0
openat(AT_FDCWD, "test.png-10.ppm", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
close(4) = 0
openat(AT_FDCWD, "test.png-11.ppm", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
close(4) = 0
openat(AT_FDCWD, "test.png-12.ppm", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
close(4) = 0
openat(AT_FDCWD, "test.png-13.ppm", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
close(4) = 0
munmap(0x7fa42ae38000, 6320128) = 0
munmap(0x7fa42ac36000, 2105344) = 0
close(3) = 0
munmap(0x7fa42b43f000, 266240) = 0
exit_group(0) = ?
+++ exited with 0 +++
~/tmp/pdf$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment