[BUG] cannot find GOT entry for '0xb0' for two type of TLS reference
There maybe not support for two type of TLS reference which causes make patch failure.
- Global TLS variable reference A simple sample is that we changed code in tls_shared as follow: cat libtls_shared.c #include <stdio.h>
__thread int tls_abc = 10;
void print_second_greetings(void) { tls_abc = 10; printf("Hello from UNPATCHED shared library\n"); }
void print_third_greetings(void) { printf("Hello from PATCHED shared library!\n"); }
void print_greetings(void) { print_second_greetings(); }
IIUC, the GOT offset should be the same as static global TLS variable. However, the code as follow seems not vaild: if (ELF64_R_SYM(rela->r_info) == 0 && rela->r_addend == tls_offset) return rela->r_offset;
- Global TLS variable reference which is reference as extern and defined in other c file A simple sample is that we changed code in tls_simple as follow:
`tls_simple.c: #include <stdio.h> #include <time.h> #include <stdlib.h> #include <my.h>
int *p;
void print_greetings(void) { printf("TLS UNPATCHED\n"); }
int main() { v = 0xDEADBEAF; p = &v;
while (1) {
print_greetings();
sleep(1);
}
return 0;
}
my.h extern __thread v;
my.c: #include <stdio.h>
__thread v = 0;`
Since TLS variable finish relocations in static link, the .rela.dyn should not include TLS variable. As for now, libcare still to do --rel-fixup and find this TLS variable in relocation table which results in make patch failure. IIUC, we should just simply not to do --rel-fixup as same as R_X86_64_TPOFF32?