Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Apr 2021 01:56:57 GMT
From:      Alex Richardson <arichardson@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 32231805fbe2 - main - linker_set: fix globl/weak symbol redefinitions to work on clang 12
Message-ID:  <202104200156.13K1uvbI029406@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by arichardson:

URL: https://cgit.FreeBSD.org/src/commit/?id=32231805fbe2b9438c2de50c229b43c016207a08

commit 32231805fbe2b9438c2de50c229b43c016207a08
Author:     Greg V <greg@unrelenting.technology>
AuthorDate: 2021-04-20 00:47:15 +0000
Commit:     Alex Richardson <arichardson@FreeBSD.org>
CommitDate: 2021-04-20 01:56:24 +0000

    linker_set: fix globl/weak symbol redefinitions to work on clang 12
    
    In clang 12.0.0.rc2, going from weak to global is now a hard error:
    
    ```
    /usr/src/stand/libsa/amd64/_setjmp.S:67:25: error: _longjmp changed binding to STB_GLOBAL
    .text; .p2align 4,0x90; .globl _longjmp; .type _longjmp,@function; _longjmp:; .cfi_startproc
    ```
    
    And the other way is a warning, but we have -Werror:
    
    ```
    error: __start_set_Xcommand_set changed binding to STB_WEAK [-Werror,-Winline-asm]
    error: __stop_set_Xcommand_set changed binding to STB_WEAK [-Werror,-Winline-asm]
    ```
    
    ref: https://reviews.llvm.org/D90108
    
    Reviewed By:    arichardson
    MFC after:      1 week
    Differential Revision: https://reviews.freebsd.org/D29159
---
 sys/sys/cdefs.h      | 4 ++--
 sys/sys/linker_set.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h
index 1d1fe2965c69..ff461db9ec2e 100644
--- a/sys/sys/cdefs.h
+++ b/sys/sys/cdefs.h
@@ -563,8 +563,8 @@
 #endif	/* __STDC__ */
 #endif	/* __GNUC__ */
 
-#define	__GLOBL1(sym)	__asm__(".globl " #sym)
-#define	__GLOBL(sym)	__GLOBL1(sym)
+#define	__GLOBL(sym)	__asm__(".globl " __XSTRING(sym))
+#define	__WEAK(sym)	__asm__(".weak " __XSTRING(sym))
 
 #if defined(__GNUC__)
 #define	__IDSTRING(name,string)	__asm__(".ident\t\"" string "\"")
diff --git a/sys/sys/linker_set.h b/sys/sys/linker_set.h
index 6169a3499dad..f957858ada04 100644
--- a/sys/sys/linker_set.h
+++ b/sys/sys/linker_set.h
@@ -60,8 +60,8 @@
  */
 #ifdef __GNUCLIKE___SECTION
 #define __MAKE_SET_QV(set, sym, qv)			\
-	__GLOBL(__CONCAT(__start_set_,set));		\
-	__GLOBL(__CONCAT(__stop_set_,set));		\
+	__WEAK(__CONCAT(__start_set_,set));		\
+	__WEAK(__CONCAT(__stop_set_,set));		\
 	static void const * qv				\
 	__set_##set##_sym_##sym __section("set_" #set)	\
 	__nosanitizeaddress				\



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202104200156.13K1uvbI029406>