Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

export: Add __gendwarfksyms_ptr_ references to exported symbols

With gendwarfksyms, we need each TU where the EXPORT_SYMBOL() macro
is used to also contain DWARF type information for the symbols it
exports. However, as a TU can also export external symbols and
compilers may choose not to emit debugging information for symbols not
defined in the current TU, the missing types will result in missing
symbol versions. Stand-alone assembly code also doesn't contain type
information for exported symbols, so we need to compile a temporary
object file with asm-prototypes.h instead, and similarly need to
ensure the DWARF in the temporary object file contains the necessary
types.

To always emit type information for external exports, add explicit
__gendwarfksyms_ptr_<symbol> references to them in EXPORT_SYMBOL().
gendwarfksyms will use the type information for __gendwarfksyms_ptr_*
if needed. Discard the pointers from the final binary to avoid further
bloat.

Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

authored by

Sami Tolvanen and committed by
Masahiro Yamada
d7476f24 fa624569

+15
+15
include/linux/export.h
··· 52 52 53 53 #else 54 54 55 + #ifdef CONFIG_GENDWARFKSYMS 56 + /* 57 + * With CONFIG_GENDWARFKSYMS, ensure the compiler emits debugging 58 + * information for all exported symbols, including those defined in 59 + * different TUs, by adding a __gendwarfksyms_ptr_<symbol> pointer 60 + * that's discarded during the final link. 61 + */ 62 + #define __GENDWARFKSYMS_EXPORT(sym) \ 63 + static typeof(sym) *__gendwarfksyms_ptr_##sym __used \ 64 + __section(".discard.gendwarfksyms") = &sym; 65 + #else 66 + #define __GENDWARFKSYMS_EXPORT(sym) 67 + #endif 68 + 55 69 #define __EXPORT_SYMBOL(sym, license, ns) \ 56 70 extern typeof(sym) sym; \ 57 71 __ADDRESSABLE(sym) \ 72 + __GENDWARFKSYMS_EXPORT(sym) \ 58 73 asm(__stringify(___EXPORT_SYMBOL(sym, license, ns))) 59 74 60 75 #endif