Bug 24286 – String literals not merged by linker because of wrong ELF output

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2023-12-18T11:55:31Z
Last change time
2024-12-13T19:32:11Z
Keywords
pull
Assigned to
No Owner
Creator
Dennis
Moved to GitHub: dmd#18202 →

Comments

Comment #0 by dkorpel — 2023-12-18T11:55:31Z
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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18202 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB