[Issue 24286] New: String literals not merged by linker because of wrong ELF output
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Dec 18 11:55:31 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=24286
Issue ID: 24286
Summary: String literals not merged by linker because of wrong
ELF output
Product: D
Version: D2
Hardware: All
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: dkorpel at live.nl
When compiled separately, the following succeeds with LDC but fails with DMD on
linux:
```D
extern(C) string getHello() { return "hello"; }
```
```D
extern(C) string getHello();
void main()
{
assert(getHello.ptr == "hello".ptr);
}
```
The reasons is that DMD generates invalid string sections, which have SHF_MERGE
| SHF_STRINGS but sh_entisze = 0 instead of char.sizeof. See:
https://github.com/dlang/dmd/pull/15915
--
More information about the Digitalmars-d-bugs
mailing list