It is used in linux kernel script:
http://lxr.free-electrons.com/source/arch/x86/kernel/vmlinux.lds.S#L140
Though CONSTRUCTORS is ignored for ELF.
Differential D28951
[ELF] - Linkerscripts: ignore CONSTRUCTORS in output section declaration. grimar on Jan 20 2017, 7:25 AM. Authored by
Details It is used in linux kernel script: Though CONSTRUCTORS is ignored for ELF.
Diff Detail Event TimelineComment Actions Can you give me a pointer to verify that the directive is ignored?
Comment Actions As I said, we need to write readable code so that even the first-time readers can understand it. If you were a stranger who happens to read this piece of code, you would wonder what this directive is and why it is ignored. Please write comments to describe why you are doing this. (I'm not saying that this needs a lengthy comment, but writing zero comments is not ok.) Comment Actions Original patch did not require comments because had elf::log with clear message. I'll add comment and remove elf::log. Comment Actions That error message was not a replacement for comments because it didn't answer what CONSTRUCTOR is. Is it a new feature that our linker does not support yet, or is it for a bug compatibility, or for compatibility with other object file formats? Don't you wonder that kind of things if you just read your code as a third person? You should mention that CONSTRUCTORS is for the a.out format which died out in '90s in major Unix systems but we need to accept it for compatibility. Comment Actions FYI the FreeBSD fix for this is here: https://svnweb.freebsd.org/changeset/base/303442 The linker script CONSTRUCTORS keyword is only meaningful "when linking object file formats which do not support arbitrary sections, such as ECOFF and XCOFF"[1] and is ignored for other object file formats. LLVM's lld does not yet accept (and ignore) CONSTRUCTORS, so just remove CONSTRUCTORS from the linker scripts as it has no effect. [1] https://sourceware.org/binutils/docs/ld/Output-Section-Keywords.html Comment Actions
Comment Actions Are you sure that this CONSTRUCTORS is trying to be a linker keyword? The nearby DATA_DATA is actually a macro expanded from http://src.illumos.org/source/xref/linux-master/include/asm-generic/vmlinux.lds.h#205 Comment Actions Yeah, CONSTRUCTORS is a linker command https://www.sourceware.org/binutils/docs-2.10/ld_3.html#SEC29 Comment Actions Also funny they still have that in their linker script as it seems that the semantic action associated for that on ELF is none (and I'll be surprised if linux runs on non-ELF, FWIW) Comment Actions Yes, I am aware this could be macros, but it is not in this case. I verified this when wrote the patch. .data : AT(ADDR(.data) - 0xffffffff80000000) { /* Start of data section */ _sdata = .; /* init_task */ . = ALIGN(((1 << 12) << (2 + 0))); __start_init_task = .; *(.data..init_task) __end_init_task = .; . = ALIGN((1 << 12)); *(.data..page_aligned) . = ALIGN((1 << (6))); *(.data..cacheline_aligned) *(.data .data.[0-9a-zA-Z_]*) *(.ref.data) *(.data..shared_aligned) *(.meminit.data) *(.memexit.data) *(.data.unlikely) . = ALIGN(32); *(__tracepoints) . = ALIGN(8); __start___jump_table = .; KEEP(*(__jump_table)) __stop___jump_table = .; . = ALIGN(8); __start___verbose = .; KEEP(*(__verbose)) __stop___verbose = .; __start___trace_bprintk_fmt = .; KEEP(*(__trace_printk_fmt)) __stop___trace_bprintk_fmt = .; __start___tracepoint_str = .; KEEP(*(__tracepoint_str)) __stop___tracepoint_str = .; CONSTRUCTORS /* rarely changed data like cpu maps */ . = ALIGN((1 << 6)); *(.data..read_mostly) . = ALIGN((1 << 6)); /* End of data section */ _edata = .; } :data Comment Actions LGTM
|
We have a lot of things we silently ignore, and I don't find this is special, so no need to print out a message for that.