Merge pull request #20403 from Homebrew/skip-proto-relocation

Skip rpath relocation of ELF files with `protodesc_cold` sections
This commit is contained in:
Mike McQuaid 2025-08-11 07:29:36 +00:00 committed by GitHub
commit 68940af4a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 2 deletions

View File

@ -19,6 +19,9 @@ class Keg
def change_rpath!(file, old_prefix, new_prefix)
return false if !file.elf? || !file.dynamic_elf?
# Skip relocation of files with `protodesc_cold` sections because patchelf.rb seems to break them.
# https://github.com/Homebrew/homebrew-core/pull/232490#issuecomment-3161362452
return false if Hardware::CPU.intel? && file.section_names.include?("protodesc_cold")
updated = {}
old_rpath = file.rpath

View File

@ -143,9 +143,17 @@ module ELFShim
save_using_patchelf_rb interpreter, rpath
end
def elf_parser
@elf_parser ||= patchelf_patcher.elf
end
sig { returns(T::Boolean) }
def dynamic_elf?
@dynamic_elf ||= patchelf_patcher.elf.segment_by_type(:DYNAMIC).present?
@dynamic_elf ||= elf_parser.segment_by_type(:DYNAMIC).present?
end
def section_names
@section_names ||= elf_parser.sections.map(&:name).compact_blank
end
# Helper class for reading metadata from an ELF file.
@ -194,7 +202,7 @@ module ELFShim
end
# Check if DF_1_NODEFLIB is set
dt_flags_1 = path.patchelf_patcher.elf.segment_by_type(:dynamic)&.tag_by_type(:flags_1)
dt_flags_1 = path.elf_parser.segment_by_type(:dynamic)&.tag_by_type(:flags_1)
nodeflib_flag = if dt_flags_1.nil?
false
else