In my previous post, LLVM integrated assembler: Improving expressions and relocations delved into enhancements made to LLVM's expression resolving and relocation generation. This post covers recent refinements to MC, focusing on sections and symbols.
Sections
1 | class MCSection { |
Previously, the MCSection class used an enum called
SectionVariant to differentiate between various object file
formats, such as ELF, Mach-O, and COFF. These subclasses are used in
contexts where the section type is known at compile-time, such as in
MCStreamer and MCObjectTargetWriter. This
change eliminates the need for runtime type information (RTTI) checks,
simplifying the codebase and improving efficiency.
Additionally, the storage for fragments' fixups (adjustments to
addresses and offsets) has been moved into the MCSection
class.
Symbols
1 | class MCSymbol { |
Similar to sections, the MCSymbol class also used a
discriminator enum, SymbolKind, to distinguish between object file
formats. This enum has also been removed.
Furthermore, the MCSymbol class had an
enum Contents to specify the kind of symbol. This name was
a bit confusing, so it has been renamed to enum Kind for
clarity.
- regular symbol
- equated symbol
- common symbol
A special enumerator, SymContentsTargetCommon, which was
used by AMDGPU for a specific type of common symbol, has also been
removed. The functionality it provided is now handled by updating
ELFObjectWriter to respect the symbol's section index
(SHN_AMDGPU_LDS for this special AMDGPU symbol).
The previous blog post LLVM integrated assembler: Improving expressions and relocations describes other changes:
- The
MCSymbol::IsUsedflag was a workaround for detecting a subset of invalid reassignments and is removed. - The
MCSymbol::IsResolvingflag is added to detect cyclic dependencies of equated symbols.