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

[BUG] cannot find GOT entry for '0xb0' for two type of TLS reference #58

Open
zhengchuan-salut opened this issue Nov 24, 2020 · 0 comments

Comments

@zhengchuan-salut
Copy link

zhengchuan-salut commented Nov 24, 2020

There maybe not support for two type of TLS reference which causes make patch failure.

  1. 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;

  1. 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?

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

No branches or pull requests

1 participant