GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
i386 Performance Win

i386: Align __mcount_loc entries for improved relocation efficiency

Aligns profiling metadata entries on i386 to reduce relocation overhead in PIE builds.

On i386, the -mrecord-mcount option previously emitted __mcount_loc entries without alignment, leading to less efficient RELA relocations in Position Independent Executables (PIE). This change aligns these entries to their size, mirroring existing practices for __patchable_function_entries. This optimization significantly reduces the number of relocations required for PIE builds of the x86_64 Linux kernel.

In Details

The -mrecord-mcount feature in GCC for i386 generates metadata for function profiling. Commit b2e128f2d58ad1db099f0eb42ca74cfe5b262350 aligns the __mcount_loc section entries to their size. This is crucial for PIE builds where linkers like ld and lld only utilize packed relative relocations for sections with at least 2-byte alignment. Without proper alignment, each entry requires a larger, less efficient RELA relocation. The generic code already aligns __patchable_function_entries, and this change harmonizes the behavior for __mcount_loc.

For Context
PIE
Position Independent Executable. A binary that can be loaded at any memory address without modification, primarily used for security and efficient memory sharing.
RELA relocation
A type of relocation record used in ELF object files. RELA records contain an explicit addend, which is added to the relocation value. They are typically used for 64-bit architectures or when explicit addends are needed.
RELR relocation
A compact relocation format used in ELF. RELR relocations are space-efficient for Position Independent Code (PIC) and PIE by embedding relocation information directly within the section, often requiring the section to be aligned.
x86_64 Linux kernel
The 64-bit version of the Linux operating system kernel, widely used on servers and desktops.
Filed Under: i386optimizationprofilingrelocations