Compare SEC_MERGE literals by their merged addresses
Fixes Xtensa linker to correctly handle duplicate mergeable string literals.
The Xtensa linker’s duplicate literal handling has been corrected to compare literals based on their final merged addresses, rather than their initial offsets. This resolves an issue where mergeable string literals could be incorrectly coalesced, leading to incorrect code.
In Details
In Xtensa's linker, SEC_MERGE sections (typically for string literals) can have duplicates coalesced. Previously, the linker determined duplicates by comparing input section offsets. This is incorrect because merging can move strings, making their final addresses differ. This commit changes the comparison to use the actual merged_offset after relocation, ensuring that literals pointing to the same string content (even if initially at different offsets due to merging) are correctly identified and handled, preventing incorrect code generation.
- SEC_MERGE
- A section flag indicating that duplicate sections (e.g., string literals) should be merged together by the linker. This is often used to save space by storing identical strings only once.
- literal
- In this context, a small piece of data (often a string or a small constant) embedded directly within the code or data section, typically referenced by special instructions or relocation entries.
- coalesced
- When the linker merges identical sections or data items, reducing redundancy and saving space. For example, multiple identical string literals might be coalesced into a single instance.