[1/3] elf: Replace .tls_common with .tbss definition

Message ID 20210726035802.275992-2-maskray@google.com
State Superseded
Headers
Series [1/3] elf: Replace .tls_common with .tbss definition |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Fangrui Song July 26, 2021, 3:58 a.m. UTC
  .tls_common is obsoleted, not supported by clang -fintegrated-as or ld.lld.
Just change it to .tbss for portability.
---
 elf/tls-macros.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Comments

H.J. Lu July 29, 2021, 2:26 p.m. UTC | #1
On Sun, Jul 25, 2021 at 8:59 PM Fangrui Song via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> .tls_common is obsoleted, not supported by clang -fintegrated-as or ld.lld.
> Just change it to .tbss for portability.

Please update the commit log for BZ #28152

>
> ---
>  elf/tls-macros.h | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/elf/tls-macros.h b/elf/tls-macros.h
> index e25e33b0f0..a637407417 100644
> --- a/elf/tls-macros.h
> +++ b/elf/tls-macros.h
> @@ -1,7 +1,11 @@
>  /* Macros to support TLS testing in times of missing compiler support.  */
>
>  #define COMMON_INT_DEF(x) \
> -  asm (".tls_common " #x ",4,4")
> +  asm (".section .tbss\n\t" \
> +       ".globl " #x "\n\t" \
> +       ".balign 4\n\t" \
> +       #x ":\t.space 4\n\t" \
> +       ".previous")
>  /* XXX Until we get compiler support we don't need declarations.  */
>  #define COMMON_INT_DECL(x)
>
> --
> 2.32.0.432.gabb21c7263-goog
>
  
Fangrui Song July 29, 2021, 4:21 p.m. UTC | #2
On 2021-07-29, H.J. Lu wrote:
>On Sun, Jul 25, 2021 at 8:59 PM Fangrui Song via Libc-alpha
><libc-alpha@sourceware.org> wrote:
>>
>> .tls_common is obsoleted, not supported by clang -fintegrated-as or ld.lld.
>> Just change it to .tbss for portability.
>
>Please update the commit log for BZ #28152

I will be mindful when committing.

>>
>> ---
>>  elf/tls-macros.h | 6 +++++-
>>  1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/elf/tls-macros.h b/elf/tls-macros.h
>> index e25e33b0f0..a637407417 100644
>> --- a/elf/tls-macros.h
>> +++ b/elf/tls-macros.h
>> @@ -1,7 +1,11 @@
>>  /* Macros to support TLS testing in times of missing compiler support.  */
>>
>>  #define COMMON_INT_DEF(x) \
>> -  asm (".tls_common " #x ",4,4")
>> +  asm (".section .tbss\n\t" \
>> +       ".globl " #x "\n\t" \
>> +       ".balign 4\n\t" \
>> +       #x ":\t.space 4\n\t" \
>> +       ".previous")
>>  /* XXX Until we get compiler support we don't need declarations.  */
>>  #define COMMON_INT_DECL(x)
>>
>> --
>> 2.32.0.432.gabb21c7263-goog
>>
>
>
>-- 
>H.J.
  

Patch

diff --git a/elf/tls-macros.h b/elf/tls-macros.h
index e25e33b0f0..a637407417 100644
--- a/elf/tls-macros.h
+++ b/elf/tls-macros.h
@@ -1,7 +1,11 @@ 
 /* Macros to support TLS testing in times of missing compiler support.  */
 
 #define COMMON_INT_DEF(x) \
-  asm (".tls_common " #x ",4,4")
+  asm (".section .tbss\n\t" \
+       ".globl " #x "\n\t" \
+       ".balign 4\n\t" \
+       #x ":\t.space 4\n\t" \
+       ".previous")
 /* XXX Until we get compiler support we don't need declarations.  */
 #define COMMON_INT_DECL(x)