diff --git a/src/elf_relocation.c b/src/elf_relocation.c index 9393a69b28a8f64df9e21e0b095a5aa3faac7c6b..9f7b2e4bd51cfdc84dda98d9c7b92508c4e3ad0a 100644 --- a/src/elf_relocation.c +++ b/src/elf_relocation.c @@ -244,7 +244,6 @@ void modify_rela_dyn_item(elf_link_t *elf_link, elf_file_t *src_ef, Elf64_Rela * case R_X86_64_TPOFF32: // Offset in initial TLS block // 00000000001f0d78 0000000000000012 R_X86_64_TPOFF64 38 - // [36] .data PROGBITS 00000000001f1000 1f0000 0016a8 00 WA 0 0 32 dst_rela->r_addend = elf_get_new_tls_offset(elf_link, src_ef, src_rela->r_addend); break; case R_X86_64_COPY: diff --git a/tests/meson.build b/tests/meson.build index 73177caef2211c5f577af1969f5251e485cd22ef..3f6d3a00e8846b3deeb98b7b590112f74cb38fcf 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -7,7 +7,7 @@ foreach test:tests sources = [] includes = [] cflags = [] - ldflags = ['-Wl,--emit-relocs', '-Wl,-z,relro,-z,now'] + ldflags = ['-Wl,--emit-relocs', '-Wl,-z,relro,-z,now', '-pie'] subdir(name) -endforeach \ No newline at end of file +endforeach diff --git a/tests/test_app/Makefile b/tests/test_app/Makefile index 50dac747827da379308e8385f563d4423ff757e6..616c3df5341bc82072febd3c59f2b3183a3e1aa6 100644 --- a/tests/test_app/Makefile +++ b/tests/test_app/Makefile @@ -12,6 +12,8 @@ LIBHOOK_R=/usr/lib/relocation/libhook.so.relocation LIBC=/usr/lib64/libc.so.6 LIBC_R=/usr/lib/relocation$(LIBC).relocation +MODE?=--static-nold +#MODE=--static-nolibc .PHONY: all @@ -51,22 +53,25 @@ run1: test-s: prepare clear @echo ===rto=== - $(SYSBOOST) --static $(TEST_APP) $(LIB1) $(LIB2) $(LIBC) + $(SYSBOOST) $(MODE) $(TEST_APP) $(LIB1) $(LIB2) $(LIBC) readelf -W -a $(TEST_APP).rto > test_app.rto.elf objdump -d $(TEST_APP).rto > test_app.rto.asm - @echo ===run-ori=== + @echo ===old=== $(TEST_APP) @echo ===run=== - ./test_app.rto + $(TEST_APP).rto rto: - gdb --args $(SYSBOOST) --static $(TEST_APP) $(LIB1) $(LIB2) $(LIBC) + gdb --args $(SYSBOOST) $(MODE) $(TEST_APP) $(LIB1) $(LIB2) $(LIBC) run: - gdb --args ./test_app.rto + gdb --args $(TEST_APP).rto env: echo 0 > /proc/sys/kernel/randomize_va_space cat /proc/sys/kernel/randomize_va_space readelf -W -a $(LIBC) > libc.so.elf objdump -d $(LIBC) > libc.so.asm + +clean: + $(RM) *.o *.ro *.old *.so *.asm *.elf *.rto *.out test_app diff --git a/tests/test_app/meson.build b/tests/test_app/meson.build index 98f05cbaad6eb9345227ecbea349900120ef351a..67f90c41043441009f84bfed7623c6a77d1b39fa 100644 --- a/tests/test_app/meson.build +++ b/tests/test_app/meson.build @@ -4,6 +4,7 @@ sources = files(['common_func.c', cflags += ['-fpic', '-pthread', '-ldl'] ldflags += ['-pie', '-ldl'] +lk_args += ['-Wl,--emit-relocs', '-Wl,-z,relro,-z,now'] # Add a target for libutil2.so shared library util1 = shared_library('util1', 'util1.c', @@ -31,4 +32,4 @@ executable('test_app', sources, link_args: ldflags, build_rpath : './', dependencies: test_app_dep, - include_directories: includes) \ No newline at end of file + include_directories: includes) diff --git a/tests/test_simple/Makefile b/tests/test_simple/Makefile index c6e2de043590d90c67e969f2f1cdaf3811d3f76e..14648e36a61a6735e0be4d1027dc4bb1217597a0 100644 --- a/tests/test_simple/Makefile +++ b/tests/test_simple/Makefile @@ -60,8 +60,8 @@ env: cat /proc/sys/kernel/randomize_va_space readelf -W -a $(LIBC_R) > libc.so.elf objdump -d $(LIBC_R) > libc.so.asm - readelf -W -a $(LIBLD_R) > ld.so.elf - objdump -d $(LIBLD_R) > ld.so.asm + readelf -W -a $(LIBLD) > ld.so.elf + objdump -d $(LIBLD) > ld.so.asm clean: $(RM) *.o *.ro *.old *.so *.asm *.elf *.rto *.out simple_app