llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

accepting __attribute__((section("__ksymtab_strings"))) on mach-o

Open echristo opened this issue 15 years ago • 4 comments

Bugzilla Link 10417
Resolution INVALID
Resolved on Jul 19, 2011 20:05
Version trunk
OS All
CC @efriedma-quic

Extended Description

llvm-gcc/gcc accepts this code from 2006-07-31-#854 .c:

struct kernel_symbol { unsigned long value; }; unsigned long loops_per_jiffy = (1<<12); static const char __kstrtab_loops_per_jiffy[] attribute((section("__ksymtab_strings"))) = "loops_per_jiffy"; static const struct kernel_symbol __ksymtab_loops_per_jiffy attribute((used)) attribute((section("__ksymtab"))) = { (unsigned long)&loops_per_jiffy, __kstrtab_loops_per_jiffy };

echristo avatar Jul 20 '11 02:07 echristo

Excellent. I seemed to recall a time when it didn't I think is the reason. I'll close this though.

echristo avatar Jul 20 '11 03:07 echristo

You may be able to convince gcc to print it, but the Darwin assembler rejects it.

efriedma-quic avatar Jul 20 '11 03:07 efriedma-quic

Mmmm.. actually just gcc-4.2:

[yendi:~] echristo% gcc-4.2 foo.c -S -o - .globl _loops_per_jiffy .data .align 3 _loops_per_jiffy: .quad 4096 .section __ksymtab_strings ___kstrtab_loops_per_jiffy: .ascii "loops_per_jiffy\0" foo.c:9: warning: excess elements in struct initializer foo.c:9: warning: (near initialization for ‘__ksymtab_loops_per_jiffy’) .no_dead_strip ___ksymtab_loops_per_jiffy .section __ksymtab .align 3 ___ksymtab_loops_per_jiffy: .quad _loops_per_jiffy .subsections_via_symbols

echristo avatar Jul 20 '11 02:07 echristo

Err, it does? There's no way that's valid on Darwin.

efriedma-quic avatar Jul 20 '11 02:07 efriedma-quic