Skip to content

[Bolt][aarch64] Some problems encountered when running shared libraries optimized by llvm-bolt #164808

@jiovf

Description

@jiovf

Hello, @bgergely0
After applying the 120064 patch and optimizing shared libraries with Bolt, encountered an issue with __cfi_check during system operation. What is the reason for this?

When this library runs on the system, the following error message appears:
_F linker :CANNOT LINK EXECUTABLE "xx-service": unaligned _cfi_check in the library "liba.so"

The log for bolt optimization is as follows:
llvm-bolt "liba.so" -o "liba.bolt" -data="liba.yaml"
--reorder-blocks=ext-tsp
--reorder-functions=cdsort
--split-functions
--split-strategy=profile2
--split-eh
--dyno-stats
--no-huge-pages
--align-text=0x4000
--infer-stale-profile
--update-debug-sections
--skip-funcs=_RNvNtCs9ayzTb0J3Pg_3std9panicking12default_hook/1
BOLT-INFO: shared object or position-independent executable detected
BOLT-INFO: Target architecture: aarch64
BOLT-INFO: BOLT version: 9df34a1
BOLT-INFO: first alloc address is 0x0
BOLT-INFO: creating new program header table at address 0x40000, offset 0x40000
BOLT-WARNING: debug info will be stripped from the binary. Use -update-debug-sections to keep it.
BOLT-INFO: enabling relocation mode
BOLT-WARNING: sizes differ for function __typeid__ZTSFviE_global_addr/1. FDE : 8; symbol table : 1. Using max size.
BOLT-WARNING: sizes differ for function __typeid__ZTSFvOZNSt3__116__variant_detail6__dtorINS0_8__traitsIJN4aidl7android8hardware6common12NativeHandleENS5_14HardwareBufferENS5_5media11bufferpool219BufferStatusMessageEEEELNS0_6_TraitE1EE9__destroyB8nn180000EvEUlRT_E_RNS0_6__baseILSD_1EJS7_S8_SB_EEEE_global_addr/1. FDE : 24; symbol table : 1. Using max size.
BOLT-INFO: using ZNSt3__116__variant_detail12__visitation6__base12__dispatcherIJLm1EEE10__dispatchB8nn180000IOZNS0_6__dtorINS0_8__traitsIJN4aidl7android8hardware6common12NativeHandleENSA_14HardwareBufferENSA_5media11bufferpool219BufferStatusMessageEEEELNS0_6_TraitE1EE9__destroyB8nn180000EvEUlRT_E_JRNS0_6__baseILSI_1EJSC_SD_SG_EEEEEEDcSK_DpT0/1 as another entry to function ZNSt3__116__variant_detail12__visitation6__base12__dispatcherIJLm0EEE10__dispatchB8nn180000IOZNS0_6__dtorINS0_8__traitsIJN4aidl7android8hardware6common12NativeHandleENSA_14HardwareBufferENSA_5media11bufferpool219BufferStatusMessageEEEELNS0_6_TraitE1EE9__destroyB8nn180000EvEUlRT_E_JRNS0_6__baseILSI_1EJSC_SD_SG_EEEEEEDcSK_DpT0/1(*4)
...
BOLT-INFO: pre-processing profile using YAML profile reader
BOLT-INFO: MarkRAStates ran on 255 functions. Ignored 0 functions (0.00%) because of CFI inconsistencies
BOLT-INFO: number of removed linker-inserted veneers: 0
BOLT-INFO: 93 out of 379 functions in the binary (24.5%) have non-empty execution profile
BOLT-INFO: profile quality metrics for the hottest 93 functions (reporting top 5% values): function CFG discontinuity 100.00%; call graph flow conservation gap 100.00%; CFG flow conservation gap 100.00% (weighted) 100.00% (worst); exception handling usage 0.00% (of total BBEC) 0.00% (of total InvokeEC)
BOLT-INFO: basic block reordering modified layout of 86 functions (92.47% of profiled, 14.48% of total)
BOLT-INFO: 1 Functions were reordered by LoopInversionPass
BOLT-INFO: program-wide dynostats after all optimizations before SCTC and FOP:

          277895 : executed forward branches
          154614 : taken forward branches
           70506 : executed backward branches
           27772 : taken backward branches
           60073 : executed unconditional branches
          268495 : all function calls
          108695 : indirect calls
          102884 : PLT calls
         2830081 : executed instructions
          598427 : executed load instructions
          411384 : executed store instructions
               0 : taken jump table branches
               0 : taken unknown indirect branches
          408474 : total branches
          242459 : taken branches
          166015 : non-taken conditional branches
          182386 : taken conditional branches
          348401 : all conditional branches
               0 : linker-inserted veneer calls

          278636 : executed forward branches (+0.3%)
            3108 : taken forward branches (-98.0%)
           69765 : executed backward branches (-1.1%)
            8670 : taken backward branches (-68.8%)
           16068 : executed unconditional branches (-73.3%)
          268495 : all function calls (=)
          108695 : indirect calls (=)
          102884 : PLT calls (=)
         2829294 : executed instructions (-0.0%)
          598427 : executed load instructions (=)
          411384 : executed store instructions (=)
               0 : taken jump table branches (=)
               0 : taken unknown indirect branches (=)
          364469 : total branches (-10.8%)
           27846 : taken branches (-88.5%)
          336623 : non-taken conditional branches (+102.8%)
           11778 : taken conditional branches (-93.5%)
          348401 : all conditional branches (=)
               0 : linker-inserted veneer calls (=)

BOLT-INFO: Starting stub-insertion pass
BOLT-INFO: Inserted 40 stubs in the hot area and 18 stubs in the cold area. Shared 0 times, iterated 2 times.
BOLT-INFO: rewritten pac-ret DWARF info in 255 out of 594 functions (42.93%).
BOLT-INFO: patched build-id (flipped last bit)
BOLT-INFO: setting __hot_start to 0x44000
BOLT-INFO: setting __hot_end to 0x4b478

  • Result: SUCCESS (took 0 seconds)
  • Output size: 572K

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions