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
Comment #1 by dlang-bot — 2023-12-18T12:03:12Z
@dkorpel created dlang/dmd pull request #15922 "Fix 24286 - String literals not merged by linker because of wrong ELF output" fixing this issue:
- Fix 24286 - String literals not merged by linker because of wrong ELF output
https://github.com/dlang/dmd/pull/15922
Comment #2 by robert.schadek — 2024-12-13T19:32:11Z