Skip to content

Skip rpath relocation of ELF files with protodesc_cold sections #20403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Library/Homebrew/extend/os/linux/keg_relocate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def relocate_dynamic_linkage(relocation)

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
Expand Down
12 changes: 10 additions & 2 deletions Library/Homebrew/os/linux/elf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,17 @@ def patch!(interpreter: nil, rpath: nil)
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.
Expand Down Expand Up @@ -194,7 +202,7 @@ def find_full_lib_path(basename)
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
Expand Down
Loading