[llvm-bugs] [Bug 45460] New: Add warning for misplaced TLS sections in linker scripts
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Apr 7 06:47:52 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=45460
Bug ID: 45460
Summary: Add warning for misplaced TLS sections in linker
scripts
Product: lld
Version: unspecified
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: ELF
Assignee: unassignedbugs at nondot.org
Reporter: jh7370.2008 at my.bristol.ac.uk
CC: llvm-bugs at lists.llvm.org, smithp352 at googlemail.com
The rules for where TLS sections can go are fairly specific. They obviously
must be in the PT_TLS segment (and should be the only ones in said segment),
but also the .tbss section (along with any other SHT_NOBITS TLS sections)
should be at the end of the segment too, and not in any other segment.
Since it's fairly easy to accidentally craft linker scripts that violate one or
more of these rules, it would be nice if a warning could be emitted if
something isn't right, to stop people writing linker scripts that produce
broken output.
Possible examples:
1) TLS sections not in TLS segment:
PHDRS {
ph_load PT_LOAD FLAGS (0x2 | 0x4);
}
SECTIONS {
.tdata : { *(.tdata) } : ph_load
}
warning: SHF_TLS section should be assigned to a PT_TLS segment
2) Non-TLS section in TLS segment (caveat - we need to handle empty output
sections here carefully):
PHDRS {
ph_load PT_LOAD FLAGS (0x2 | 0x4);
ph_tls PT_TLS FLAGS (0x2 | 0x4);
}
SECTIONS {
.tdata : { *(.tdata) } : ph_load : ph_tls
.data : { *(.data) }
}
warning: non-SHF_TLS section should not be assigned to a PT_TLS segment
3) Non SHT_NOBITS last section in TLS segment containing other NOBITS sections
(again beware of empty output sections):
PHDRS {
ph_load PT_LOAD FLAGS (0x2 | 0x4);
ph_tls PT_TLS FLAGS (0x2 | 0x4);
}
SECTIONS {
.tbss : { *(.tbss) } : ph_tls
.tdata : { *(.tdata) } : ph_load : ph_tls
}
warning: non-SHT_NOBITS section found in PT_TLS segment after SHT_NOBITS
section
4) SHT_NOBITS TLS section in non-PT_TLS segment:
PHDRS {
ph_load PT_LOAD FLAGS (0x2 | 0x4);
ph_tls PT_TLS FLAGS (0x2 | 0x4);
}
SECTIONS {
.tdata : { *(.tdata) } : ph_load : ph_tls
.tbss : { *(.tbss) }
}
warning: SHT_NOBITS TLS section in non-TLS segment
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200407/dfce8f86/attachment.html>
More information about the llvm-bugs
mailing list