[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/32240] warning: relocation against `_Z5test2v' in read-only sect
From: |
federico.kircheis at gmail dot com |
Subject: |
[Bug ld/32240] warning: relocation against `_Z5test2v' in read-only section |
Date: |
Fri, 18 Oct 2024 18:11:15 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=32240
--- Comment #4 from federico.kircheis at gmail dot com <federico.kircheis at
gmail dot com> ---
Hello @Nick
Thank you for the constructive feedback.
> What is your target architecture ?
I'm using debian amd64, thus it is strange that you do not get the same warning
on your platform.
> Of course it is only a warning and you are free to ignore it.
Yes; but I would prefer to fix the root cause, since without a linker script I
do not get any warnings, or write the script in a way that does not generate a
warning in the first place (since the same warning could come from somewere
else and should not be ignored)
And if there is no error, then I would appreciate if the tooling improves it
diagnostics ;)
> [...] is going to end up creating *two* .rodata sections in the output
Ah, I thought too that redefining .rodata might not have been a good idea; on
the other hand, I did not like the idea to add a new section just because I
needed two symbols...
> This happens because the tests section is being placed after the .text
> section. [...] To solve this, try placing the tests section after the .data
> section instead of the .text section.
Thank you, for the hint.
With the following script
----
SECTIONS
{
tests : {
PROVIDE(tests_begin = .);
KEEP(*(.tests))
PROVIDE(tests_end = .);
}
}
INSERT AFTER .data;
----
I do not get any warning!
If I add the READONLY (which I would prefer to have, since the data is
initialized and not modified anymore), then I get the following warning again
----
/usr/bin/ld: /tmp/cc2ZjVUJ.o: warning: relocation in read-only section `.tests'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
----
> You may find that adding -Wl,-z,notext to the command line will silence the
> warning.
Confirmed, it silences the warning.
--
You are receiving this mail because:
You are on the CC list for the bug.