[PATCH v3 0/2] Fix several mix up between octets and bytes in ELF program headers
Christian Eggers
ceggers@gmx.de
Sun Feb 23 18:35:00 GMT 2020
And now the debug information:
Currently, expressions within the debug sections are resolved either to octets
or to bytes (depending on SEC_ELF_OCTETS of the symbol in the expression).
This happens within GAS, so these expression will not appear as external
symbols nor relocations.
Example 1:
TC_DWARF2_EMIT_OFFSET (section_symbol (info_seg), sizeof_offset);
resolves to octets as info_seg belongs to the .debug_info section which has
SEC_ELF_OCTETS set
Example 2:
/* DW_AT_high_pc */
...
exp.X_add_symbol = all_segs->text_end;
resolves to bytes as the .text section has no SEC_ELF_OCTETS set
The proposed change is that expressions / fixes with symbols of a non
SEC_ELF_OCTETS section...
- resolve to octets if the expression appears in a SEC_ELF_OCTETS section
- resolve to bytes if the expression appears inside another section
So the result of a fix must be multiplied with octets_per_byte if the symbol
value is bytes (e.g. !(S_IS_OCTETS (fixP->fx_addsy))) and the section of the
fix has SEC_ELF_OCTETS set. Possibly this could be done in fixup_segment()
when calling md_apply_fix().
As an alternative approach, the conversion from bytes to octets could be
"manually" triggered by setting a new flag inside expressionS / fixS, which
can be checked in fixup_segment().
- out_debug_line():
+ process_entries(): Needs 3 conversions
+ out_set_addr(): No changes
+ emit_expr()
- out_debug_ranges(): No changes
+ emit_expr()
- out_debug_aranges(): No changes
+ emit_expr()
- out_debug_abbrev(): No changes
- out_debug_str(): No changes (already octets)
- out_debug_info(): No changes
+ emit_expr()
Conclusion: In order to change debug information from bytes to octets, it
should be sufficient to perform a conversion for the generated debug line
info. Additionally, fixes applied within SEC_ELF_OCTETS sections may need
conversion to octets if the symbol value resolved to bytes.
If I could get some feedback for the proposed changes to r_offset, r_added,
st_value and debug_info, I would implement the changes soon. I hope that
together with my previous patches, the octets/bytes topic can be closed then.
Regards
Christian
More information about the Binutils
mailing list