* [PATCH 1/1] Fix AARCH64_TLSDESC relocation conflict
@ 2015-11-03 11:44 Manjeet Pawar
2015-11-03 21:10 ` Mark Hatle
0 siblings, 1 reply; 5+ messages in thread
From: Manjeet Pawar @ 2015-11-03 11:44 UTC (permalink / raw
To: yocto, mark.hatle
Cc: Vaneet Narang, ajeet.y, doha.hwang, hakbong5.lee, maninder1.s,
Manjeet Pawar, pankaj.m
This patch needs to be applied to 'cross_prelink_aarch64' branch.
It fixes tls1, tls2, tls4, tls5, tls6 test cases of prelink testsuite.
tls3 gets failed but this test case fails without prelink as well on AARCH64
Signed-off-by: Vaneet Narang <v.narang@samsung.com>
Signed-off-by: Manjeet Pawar <manjeet.p@samsung.com>
---
src/arch-aarch64.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/arch-aarch64.c b/src/arch-aarch64.c
index e04dd6e..6499c68 100644
--- a/src/arch-aarch64.c
+++ b/src/arch-aarch64.c
@@ -375,7 +375,7 @@ aarch64_prelink_conflict_rela (DSO *dso, struct prelink_info *info,
break;
case R_AARCH64_TLSDESC:
tls = conflict ? conflict->lookup.tls : info->curtls;
- ret->r_addend = rela->r_addend + tls->offset;
+ ret->r_addend = value + rela->r_addend + tls->offset;
break;
default:
error (0, 0, "%s: Unknown AARCH64 relocation type %d", dso->filename,
--
1.7.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] Fix AARCH64_TLSDESC relocation conflict
2015-11-03 11:44 Manjeet Pawar
@ 2015-11-03 21:10 ` Mark Hatle
0 siblings, 0 replies; 5+ messages in thread
From: Mark Hatle @ 2015-11-03 21:10 UTC (permalink / raw
To: Manjeet Pawar, yocto
Cc: Vaneet Narang, ajeet.y, doha.hwang, hakbong5.lee, maninder1.s,
pankaj.m
On 11/3/15 5:44 AM, Manjeet Pawar wrote:
> This patch needs to be applied to 'cross_prelink_aarch64' branch.
> It fixes tls1, tls2, tls4, tls5, tls6 test cases of prelink testsuite.
> tls3 gets failed but this test case fails without prelink as well on AARCH64
>
> Signed-off-by: Vaneet Narang <v.narang@samsung.com>
> Signed-off-by: Manjeet Pawar <manjeet.p@samsung.com>
> ---
> src/arch-aarch64.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/src/arch-aarch64.c b/src/arch-aarch64.c
> index e04dd6e..6499c68 100644
> --- a/src/arch-aarch64.c
> +++ b/src/arch-aarch64.c
> @@ -375,7 +375,7 @@ aarch64_prelink_conflict_rela (DSO *dso, struct prelink_info *info,
> break;
> case R_AARCH64_TLSDESC:
> tls = conflict ? conflict->lookup.tls : info->curtls;
> - ret->r_addend = rela->r_addend + tls->offset;
> + ret->r_addend = value + rela->r_addend + tls->offset;
> break;
> default:
> error (0, 0, "%s: Unknown AARCH64 relocation type %d", dso->filename,
>
I'm still getting segfaults here.
The way I am testing is building a Yocto Project (jethro) system
core-image-base, and adding to it:
"packagegroup-core-buildessential,libelf,elfutils-dev,binutils-staticdev,glibc-staticdev"
The copying a checked out version of the prelink-cross repository with the
prelink_cross_aarch64 branch checked out.
On the target:
autoreconf -if
./configure
make
make -C testsuite check
Most tests still fail, and all of the TLS tests result in a segfault.
(I do have the 'aarch64/dl-machine.h: Fix load-address for prelink support'
applied to my glibc. Are there any other patches that may need to be applied?)
--Mark
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] Fix AARCH64_TLSDESC relocation conflict
@ 2015-11-04 5:58 Vaneet Narang
0 siblings, 0 replies; 5+ messages in thread
From: Vaneet Narang @ 2015-11-04 5:58 UTC (permalink / raw
To: Mark Hatle
Cc: AJEET YADAV, yocto@yoctoproject.org, doha Hwang, Hak-Bong Lee,
Maninder Singh, Manjeet Pawar, PANKAJ MISHRA
On 11/3/15 5:44 AM, Manjeet Pawar wrote:
>> This patch needs to be applied to 'cross_prelink_aarch64' branch.
>> It fixes tls1, tls2, tls4, tls5, tls6 test cases of prelink testsuite.
>> tls3 gets failed but this test case fails without prelink as well on AARCH64
>
>I'm still getting segfaults here.
>
>The way I am testing is building a Yocto Project (jethro) system
>core-image-base, and adding to it:
>"packagegroup-core-buildessential,libelf,elfutils-dev,binutils-staticdev,glibc-staticdev"
>
>The copying a checked out version of the prelink-cross repository with the
>prelink_cross_aarch64 branch checked out.
>
>On the target:
>
>autoreconf -if
>./configure
>make
>make -C testsuite check
>
>Most tests still fail, and all of the TLS tests result in a segfault.
>
>(I do have the 'aarch64/dl-machine.h: Fix load-address for prelink support'
>applied to my glibc. Are there any other patches that may need to be applied?)
>
>--Mark
Hi Mark,
Apart from fixing load-address changes, I have done one more change in _dl_tlsdesc_undefweak function
of loader to handle AARCH64_TLSDESC relocation type. Samething I have mentioned in patch description of
[PATCH 1/1] prelink: AARCH64 support added. This is kind of a quick fix, so I am open to suggestion regarding proper fix.
Change done in _dl_tlsdesc_undefweak
--- a/ports/sysdeps/aarch64/dl-tlsdesc.S
+++ b/ports/sysdeps/aarch64/dl-tlsdesc.S
@@ -98,7 +98,6 @@ _dl_tlsdesc_undefweak:
cfi_adjust_cfa_offset(16)
ldr x0, [x0, #8]
mrs x1, tpidr_el0
- sub x0, x0, x1
ldr x1, [sp], #16
cfi_adjust_cfa_offset(16)
RET
Reason for this change:
To handle AARCH64_TLSDESC, I have referred below patch which state create a conflict for TLSDESC.
[yocto] [prelink-cross][PATCH] Always create a conflict for R_ARM_TLS_DESC relocs.
http://git.yoctoproject.org/cgit/cgit.cgi/prelink-cross/commit/?h=cross_prelink_aarch64&id=faa069deec99bf61418d0bab831c83d7c1b797ca
I have done the same implementation for AARCH64. Loader handles AARCH64_TLSDESC conflict as below.
case R_AARCH64_TLSDESC:
....
if (! sym)
{
td->arg = (void*)reloc->r_addend;
td->entry = _dl_tlsdesc_undefweak;
}
After this change, all the access to __thread variable will end up calling _dl_tlsdesc_undefweak function.
_dl_tlsdesc_undefweak returns addend minus thread pointer but access to __thread expects only addend as per assembly.
So removed subtraction operation from code.
Example of simple __thread variable getting accessed in shared library.
__thread int i = 10;
dummy() {
printf("Value of i %d \n",i);
}
Objdump of above code:
000000000000088c <dummy>:
890: d53bd041 mrs x1, tpidr_el0 // Read coprocessor register for thread pointer. x1 will contain thread pointer
894: 90000080 adrp x0, 10000 <__FRAME_END__+0xf628>
898: f9462802 ldr x2, [x0,#3152] // Read .got.plt section to fetch address of tls handler (_dl_tlsdesc_undefweak)
89c: 91314000 add x0, x0, #0xc50
8a0: d63f0040 blr x2 // Function call to _dl_tlsdesc_undefweak, after fuction call x0 will contain addend - thread pointer
8a4: 910003fd mov x29, sp
8a8: 90000002 adrp x2, 0 <i>
8ac: a8c17bfd ldp x29, x30, [sp],#16
8b0: b8606821 ldr w1, [x1,x0] // Access to x0 (addend - thread pointer) + x1 (thread pointer). Access to addend will result seg fault
8b4: 91234040 add x0, x2, #0x8d0
8b8: 17ffffaa b 760 <printf@plt>
So change done in loader to make _dl_tlsdesc_undefweak return only addend.
Thanks & Regards,
Vaneet Narang
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] Fix AARCH64_TLSDESC relocation conflict
@ 2015-11-06 7:09 Vaneet Narang
2015-11-06 14:26 ` Mark Hatle
0 siblings, 1 reply; 5+ messages in thread
From: Vaneet Narang @ 2015-11-06 7:09 UTC (permalink / raw
To: Mark Hatle
Cc: AJEET YADAV, yocto@yoctoproject.org, doha Hwang, Hak-Bong Lee,
Maninder Singh, Manjeet Pawar, PANKAJ MISHRA
Hi Mark,
>I have done the same implementation for AARCH64. Loader handles AARCH64_TLSDESC conflict as below.
>case R_AARCH64_TLSDESC:
>....
> if (! sym)
> {
> td->arg = (void*)reloc->r_addend;
> td->entry = _dl_tlsdesc_undefweak;
> }
we have shared one patch in libc to handle AARCH64_TLS conflict on AARCH64.
https://sourceware.org/ml/libc-alpha/2015-11/msg00106.html
Since we are using cross prelink we don't run testsuite. we compile all test cases
from test suite manually as mentioned in tls.sh file and run on target.
LD_DEBUG=libs LD_LIBRARY_PATH=. ./tls1
1828: prelink checking: ok
....
No segfault or abort() is observed hence i assume testcase is running properly.
Thanks
Vaneet Narang
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] Fix AARCH64_TLSDESC relocation conflict
2015-11-06 7:09 Vaneet Narang
@ 2015-11-06 14:26 ` Mark Hatle
0 siblings, 0 replies; 5+ messages in thread
From: Mark Hatle @ 2015-11-06 14:26 UTC (permalink / raw
To: v.narang
Cc: AJEET YADAV, yocto@yoctoproject.org, doha Hwang, Hak-Bong Lee,
Maninder Singh, Manjeet Pawar, PANKAJ MISHRA
On 11/6/15 1:09 AM, Vaneet Narang wrote:
> Hi Mark,
>
>> I have done the same implementation for AARCH64. Loader handles AARCH64_TLSDESC conflict as below.
>> case R_AARCH64_TLSDESC:
>> ....
>> if (! sym)
>> {
>> td->arg = (void*)reloc->r_addend;
>> td->entry = _dl_tlsdesc_undefweak;
>> }
>
> we have shared one patch in libc to handle AARCH64_TLS conflict on AARCH64.
> https://sourceware.org/ml/libc-alpha/2015-11/msg00106.html
>
> Since we are using cross prelink we don't run testsuite. we compile all test cases
> from test suite manually as mentioned in tls.sh file and run on target.
>
> LD_DEBUG=libs LD_LIBRARY_PATH=. ./tls1
>
> 1828: prelink checking: ok
>
> ....
> No segfault or abort() is observed hence i assume testcase is running properly.
I will look into this further. But you should start building the test cases on
the target and running them.
Some of the failures are segfault/aborts. But many of them have to do with
prelink functionality. For example, many failures are related to the inability
to 'unprelink' the binaries.
Something is changing the binary in a way that can not be reverted, and this is
a failure case. The system must be able to be unprelinked for validation
purposes -- and also to permit being re-prelinked.
I will look into merging these patches later today and will also work on adding
the necessary patches to poky/oe-core and putting them into a contrib branch so
we're working on the same set of data.
--Mark
>
> Thanks
> Vaneet Narang
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-11-06 15:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-04 5:58 [PATCH 1/1] Fix AARCH64_TLSDESC relocation conflict Vaneet Narang
-- strict thread matches above, loose matches on Subject: below --
2015-11-06 7:09 Vaneet Narang
2015-11-06 14:26 ` Mark Hatle
2015-11-03 11:44 Manjeet Pawar
2015-11-03 21:10 ` Mark Hatle
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.