2022-05-02 20:59:59 +01:00
|
|
|
# typed: true
|
|
|
|
|
2020-08-01 00:32:05 +05:30
|
|
|
# DO NOT EDIT MANUALLY
|
|
|
|
# This is an autogenerated file for types exported from the `patchelf` gem.
|
2021-09-17 19:28:50 +01:00
|
|
|
# Please instead update this file by running `bin/tapioca gem patchelf`.
|
2020-07-26 21:04:49 +05:30
|
|
|
|
2023-12-14 15:34:15 +00:00
|
|
|
# Main module of patchelf.
|
|
|
|
#
|
|
|
|
# @author david942j
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf.rb#6
|
2021-09-10 21:21:17 +01:00
|
|
|
module PatchELF; end
|
2020-07-26 21:04:49 +05:30
|
|
|
|
2023-12-14 15:34:15 +00:00
|
|
|
# Helper methods for internal usage.
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/helper.rb#5
|
2020-07-26 21:04:49 +05:30
|
|
|
module PatchELF::Helper
|
|
|
|
private
|
|
|
|
|
2023-12-14 15:34:15 +00:00
|
|
|
# @example
|
|
|
|
# aligndown(0x1234)
|
|
|
|
# #=> 4096
|
|
|
|
# aligndown(0x33, 0x20)
|
|
|
|
# #=> 32
|
|
|
|
# aligndown(0x10, 0x8)
|
|
|
|
# #=> 16
|
|
|
|
# @param val [Integer]
|
|
|
|
# @param align [Integer]
|
|
|
|
# @return [Integer] Aligned result.
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/helper.rb#65
|
2020-08-01 00:32:05 +05:30
|
|
|
def aligndown(val, align = T.unsafe(nil)); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# @example
|
|
|
|
# alignup(0x1234)
|
|
|
|
# #=> 8192
|
|
|
|
# alignup(0x33, 0x20)
|
|
|
|
# #=> 64
|
|
|
|
# alignup(0x10, 0x8)
|
|
|
|
# #=> 16
|
|
|
|
# @param val [Integer]
|
|
|
|
# @param align [Integer]
|
|
|
|
# @return [Integer] Aligned result.
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/helper.rb#80
|
2020-08-01 00:32:05 +05:30
|
|
|
def alignup(val, align = T.unsafe(nil)); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# For {#colorize} to decide if need add color codes.
|
|
|
|
#
|
|
|
|
# @return [Boolean]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/helper.rb#50
|
2020-07-26 21:04:49 +05:30
|
|
|
def color_enabled?; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# For wrapping string with color codes for prettier inspect.
|
|
|
|
#
|
|
|
|
# @param str [String] Content to colorize.
|
|
|
|
# @param type [Symbol] Specify which kind of color to use, valid symbols are defined in {.COLOR_CODE}.
|
|
|
|
# @return [String] String that wrapped with color codes.
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/helper.rb#40
|
2020-07-26 21:04:49 +05:30
|
|
|
def colorize(str, type); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# The size of one page.
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/helper.rb#17
|
2022-11-04 16:43:46 +00:00
|
|
|
def page_size(e_machine = T.unsafe(nil)); end
|
2020-07-26 21:04:49 +05:30
|
|
|
|
2020-08-01 00:32:05 +05:30
|
|
|
class << self
|
2023-12-14 15:34:15 +00:00
|
|
|
# @example
|
|
|
|
# aligndown(0x1234)
|
|
|
|
# #=> 4096
|
|
|
|
# aligndown(0x33, 0x20)
|
|
|
|
# #=> 32
|
|
|
|
# aligndown(0x10, 0x8)
|
|
|
|
# #=> 16
|
|
|
|
# @param val [Integer]
|
|
|
|
# @param align [Integer]
|
|
|
|
# @return [Integer] Aligned result.
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/helper.rb#65
|
2020-08-01 00:32:05 +05:30
|
|
|
def aligndown(val, align = T.unsafe(nil)); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# @example
|
|
|
|
# alignup(0x1234)
|
|
|
|
# #=> 8192
|
|
|
|
# alignup(0x33, 0x20)
|
|
|
|
# #=> 64
|
|
|
|
# alignup(0x10, 0x8)
|
|
|
|
# #=> 16
|
|
|
|
# @param val [Integer]
|
|
|
|
# @param align [Integer]
|
|
|
|
# @return [Integer] Aligned result.
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/helper.rb#80
|
2020-08-01 00:32:05 +05:30
|
|
|
def alignup(val, align = T.unsafe(nil)); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# For {#colorize} to decide if need add color codes.
|
|
|
|
#
|
|
|
|
# @return [Boolean]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/helper.rb#50
|
2020-08-01 00:32:05 +05:30
|
|
|
def color_enabled?; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# For wrapping string with color codes for prettier inspect.
|
|
|
|
#
|
|
|
|
# @param str [String] Content to colorize.
|
|
|
|
# @param type [Symbol] Specify which kind of color to use, valid symbols are defined in {.COLOR_CODE}.
|
|
|
|
# @return [String] String that wrapped with color codes.
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/helper.rb#40
|
2020-08-01 00:32:05 +05:30
|
|
|
def colorize(str, type); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# The size of one page.
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/helper.rb#17
|
2022-11-04 16:43:46 +00:00
|
|
|
def page_size(e_machine = T.unsafe(nil)); end
|
2020-08-01 00:32:05 +05:30
|
|
|
end
|
2020-07-26 21:04:49 +05:30
|
|
|
end
|
|
|
|
|
2023-12-14 15:34:15 +00:00
|
|
|
# Color codes for pretty print.
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/helper.rb#9
|
2020-07-26 21:04:49 +05:30
|
|
|
PatchELF::Helper::COLOR_CODE = T.let(T.unsafe(nil), Hash)
|
|
|
|
|
2023-12-14 15:34:15 +00:00
|
|
|
# A logger for internal usage.
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/logger.rb#9
|
2020-07-26 21:04:49 +05:30
|
|
|
module PatchELF::Logger
|
|
|
|
private
|
|
|
|
|
2023-12-14 15:34:15 +00:00
|
|
|
# source://patchelf//lib/patchelf/logger.rb#19
|
2020-08-28 00:20:10 +00:00
|
|
|
def debug(msg); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# source://patchelf//lib/patchelf/logger.rb#19
|
2020-07-26 21:04:49 +05:30
|
|
|
def error(msg); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# source://patchelf//lib/patchelf/logger.rb#19
|
2020-07-26 21:04:49 +05:30
|
|
|
def info(msg); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# source://patchelf//lib/patchelf/logger.rb#19
|
2020-08-28 00:20:10 +00:00
|
|
|
def level=(msg); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# source://patchelf//lib/patchelf/logger.rb#19
|
2020-07-26 21:04:49 +05:30
|
|
|
def warn(msg); end
|
|
|
|
|
2020-08-01 00:32:05 +05:30
|
|
|
class << self
|
2023-12-14 15:34:15 +00:00
|
|
|
# source://patchelf//lib/patchelf/logger.rb#19
|
2020-08-28 00:20:10 +00:00
|
|
|
def debug(msg); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# source://patchelf//lib/patchelf/logger.rb#19
|
2020-08-01 00:32:05 +05:30
|
|
|
def error(msg); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# source://patchelf//lib/patchelf/logger.rb#19
|
2020-08-01 00:32:05 +05:30
|
|
|
def info(msg); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# source://patchelf//lib/patchelf/logger.rb#19
|
2020-08-28 00:20:10 +00:00
|
|
|
def level=(msg); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# source://patchelf//lib/patchelf/logger.rb#19
|
2020-08-01 00:32:05 +05:30
|
|
|
def warn(msg); end
|
|
|
|
end
|
2020-07-26 21:04:49 +05:30
|
|
|
end
|
|
|
|
|
2023-12-14 15:34:15 +00:00
|
|
|
# Memory management, provides malloc/free to allocate LOAD segments.
|
|
|
|
#
|
|
|
|
# @private
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/mm.rb#8
|
2020-07-26 21:04:49 +05:30
|
|
|
class PatchELF::MM
|
2023-12-14 15:34:15 +00:00
|
|
|
# Instantiate a {MM} object.
|
|
|
|
#
|
|
|
|
# @param elf [ELFTools::ELFFile]
|
|
|
|
# @return [MM] a new instance of MM
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/mm.rb#14
|
2020-07-26 21:04:49 +05:30
|
|
|
def initialize(elf); end
|
|
|
|
|
2023-12-14 15:34:15 +00:00
|
|
|
# Let the malloc / free requests be effective.
|
|
|
|
#
|
|
|
|
# @return [void]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/mm.rb#35
|
2020-07-26 21:04:49 +05:30
|
|
|
def dispatch!; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# @return [Integer] The size extended.
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/mm.rb#9
|
2020-07-26 21:04:49 +05:30
|
|
|
def extend_size; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# Query if extended.
|
|
|
|
#
|
|
|
|
# @return [Boolean]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/mm.rb#57
|
2020-07-26 21:04:49 +05:30
|
|
|
def extended?; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# Get correct offset after the extension.
|
|
|
|
#
|
|
|
|
# @param off [Integer]
|
|
|
|
# @return [Integer] Shifted offset.
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/mm.rb#66
|
2020-07-26 21:04:49 +05:30
|
|
|
def extended_offset(off); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# @param size [Integer]
|
|
|
|
# @raise [ArgumentError]
|
|
|
|
# @return [void]
|
|
|
|
# @yieldparam off [Integer]
|
|
|
|
# @yieldparam vaddr [Integer]
|
|
|
|
# @yieldreturn [void] One can only do the following things in the block:
|
|
|
|
# 1. Set ELF headers' attributes (with ELFTools)
|
|
|
|
# 2. Invoke {Saver#inline_patch}
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/mm.rb#27
|
2020-07-26 21:04:49 +05:30
|
|
|
def malloc(size, &block); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# @return [Integer] Where the file start to be extended.
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/mm.rb#10
|
2020-07-26 21:04:49 +05:30
|
|
|
def threshold; end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2023-12-14 15:34:15 +00:00
|
|
|
# @raise [ArgumentError]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/mm.rb#182
|
2020-07-26 21:04:49 +05:30
|
|
|
def abnormal_elf(msg); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# source://patchelf//lib/patchelf/mm.rb#86
|
2020-08-01 00:32:05 +05:30
|
|
|
def extend_backward(seg, size = T.unsafe(nil)); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# source://patchelf//lib/patchelf/mm.rb#93
|
2020-08-01 00:32:05 +05:30
|
|
|
def extend_forward(seg, size = T.unsafe(nil)); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# source://patchelf//lib/patchelf/mm.rb#75
|
2020-07-26 21:04:49 +05:30
|
|
|
def fgap_method; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# source://patchelf//lib/patchelf/mm.rb#122
|
2020-08-01 00:32:05 +05:30
|
|
|
def find_gap(check_sz: T.unsafe(nil)); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# source://patchelf//lib/patchelf/mm.rb#174
|
2020-07-26 21:04:49 +05:30
|
|
|
def invoke_callbacks(seg, start); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# source://patchelf//lib/patchelf/mm.rb#170
|
2020-07-26 21:04:49 +05:30
|
|
|
def load_segments; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# source://patchelf//lib/patchelf/mm.rb#102
|
2020-07-26 21:04:49 +05:30
|
|
|
def mgap_method; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# TODO
|
|
|
|
#
|
|
|
|
# @raise [NotImplementedError]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/mm.rb#138
|
2020-07-26 21:04:49 +05:30
|
|
|
def new_load_method; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# For all attributes >= threshold, += offset
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/mm.rb#147
|
2020-07-26 21:04:49 +05:30
|
|
|
def shift_attributes; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# @return [Boolean]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/mm.rb#142
|
2020-07-26 21:04:49 +05:30
|
|
|
def writable?(seg); end
|
|
|
|
end
|
|
|
|
|
2023-12-14 15:34:15 +00:00
|
|
|
# Raised on missing Program Header(segment)
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/exceptions.rb#14
|
2021-09-10 21:21:17 +01:00
|
|
|
class PatchELF::MissingSegmentError < ::PatchELF::PatchError; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# Raised when Dynamic Tag is missing
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/exceptions.rb#11
|
2021-09-10 21:21:17 +01:00
|
|
|
class PatchELF::MissingTagError < ::PatchELF::PatchError; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# Raised on an error during ELF modification.
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/exceptions.rb#8
|
2021-09-10 21:21:17 +01:00
|
|
|
class PatchELF::PatchError < ::ELFTools::ELFError; end
|
2020-07-26 21:04:49 +05:30
|
|
|
|
2023-12-14 15:34:15 +00:00
|
|
|
# Class to handle all patching things.
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/patcher.rb#12
|
2020-07-26 21:04:49 +05:30
|
|
|
class PatchELF::Patcher
|
2023-12-14 15:34:15 +00:00
|
|
|
# Instantiate a {Patcher} object.
|
|
|
|
#
|
|
|
|
# @param filename [String] Filename of input ELF.
|
|
|
|
# @param logging [Boolean] *deprecated*: use +on_error+ instead
|
|
|
|
# @param on_error [:log, :silent, :exception] action when the desired segment/tag field isn't present
|
|
|
|
# :log = logs to stderr
|
|
|
|
# :exception = raise exception related to the error
|
|
|
|
# :silent = ignore the errors
|
|
|
|
# @raise [ArgumentError]
|
|
|
|
# @return [Patcher] a new instance of Patcher
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/patcher.rb#28
|
2020-08-01 00:32:05 +05:30
|
|
|
def initialize(filename, on_error: T.unsafe(nil), logging: T.unsafe(nil)); end
|
2020-07-26 21:04:49 +05:30
|
|
|
|
2023-12-14 15:34:15 +00:00
|
|
|
# Add the needed library.
|
|
|
|
#
|
|
|
|
# @note This setting will be saved after {#save} being invoked.
|
|
|
|
# @param need [String]
|
|
|
|
# @return [void]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/patcher.rb#81
|
2020-07-26 21:04:49 +05:30
|
|
|
def add_needed(need); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# @note This setting will be saved after {#save} being invoked.
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/patcher.rb#16
|
2020-07-26 21:04:49 +05:30
|
|
|
def elf; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# @example
|
|
|
|
# PatchELF::Patcher.new('/bin/ls').interpreter
|
|
|
|
# #=> "/lib64/ld-linux-x86-64.so.2"
|
|
|
|
# @return [String?] Get interpreter's name.
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/patcher.rb#44
|
2020-07-26 21:04:49 +05:30
|
|
|
def interpreter; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# Set interpreter's name.
|
|
|
|
#
|
|
|
|
# If the input ELF has no existent interpreter,
|
|
|
|
# this method will show a warning and has no effect.
|
|
|
|
#
|
|
|
|
# @note This setting will be saved after {#save} being invoked.
|
|
|
|
# @param interp [String]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/patcher.rb#54
|
2020-07-26 21:04:49 +05:30
|
|
|
def interpreter=(interp); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# Get needed libraries.
|
|
|
|
#
|
|
|
|
# @example
|
|
|
|
# patcher = PatchELF::Patcher.new('/bin/ls')
|
|
|
|
# patcher.needed
|
|
|
|
# #=> ["libselinux.so.1", "libc.so.6"]
|
|
|
|
# @return [Array<String>]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/patcher.rb#66
|
2020-07-26 21:04:49 +05:30
|
|
|
def needed; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# Set needed libraries.
|
|
|
|
#
|
|
|
|
# @note This setting will be saved after {#save} being invoked.
|
|
|
|
# @param needs [Array<String>]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/patcher.rb#73
|
2020-07-26 21:04:49 +05:30
|
|
|
def needed=(needs); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# Remove the needed library.
|
|
|
|
#
|
|
|
|
# @note This setting will be saved after {#save} being invoked.
|
|
|
|
# @param need [String]
|
|
|
|
# @return [void]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/patcher.rb#90
|
2020-07-26 21:04:49 +05:30
|
|
|
def remove_needed(need); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# Replace needed library +src+ with +tar+.
|
|
|
|
#
|
|
|
|
# @note This setting will be saved after {#save} being invoked.
|
|
|
|
# @param src [String] Library to be replaced.
|
|
|
|
# @param tar [String] Library replace with.
|
|
|
|
# @return [void]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/patcher.rb#103
|
2020-07-26 21:04:49 +05:30
|
|
|
def replace_needed(src, tar); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# Get rpath
|
|
|
|
# return [String?]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/patcher.rb#142
|
2020-07-26 21:04:49 +05:30
|
|
|
def rpath; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# Set rpath
|
|
|
|
#
|
|
|
|
# Modify / set DT_RPATH of the given ELF.
|
|
|
|
# similar to runpath= except DT_RPATH is modifed/created in DYNAMIC segment.
|
|
|
|
#
|
|
|
|
# @note This setting will be saved after {#save} being invoked.
|
|
|
|
# @param rpath [String]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/patcher.rb#152
|
2020-07-26 21:04:49 +05:30
|
|
|
def rpath=(rpath); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# Get runpath.
|
|
|
|
#
|
|
|
|
# @return [String?]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/patcher.rb#136
|
2020-07-26 21:04:49 +05:30
|
|
|
def runpath; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# Set runpath.
|
|
|
|
#
|
|
|
|
# If DT_RUNPATH is not presented in the input ELF,
|
|
|
|
# a new DT_RUNPATH attribute will be inserted into the DYNAMIC segment.
|
|
|
|
#
|
|
|
|
# @note This setting will be saved after {#save} being invoked.
|
|
|
|
# @param runpath [String]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/patcher.rb#162
|
2020-07-26 21:04:49 +05:30
|
|
|
def runpath=(runpath); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# Save the patched ELF as +out_file+.
|
|
|
|
#
|
|
|
|
# @param out_file [String?] If +out_file+ is +nil+, the original input file will be modified.
|
|
|
|
# @param patchelf_compatible [Boolean] When +patchelf_compatible+ is true, tries to produce same ELF as the one produced by NixOS/patchelf.
|
|
|
|
# @return [void]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/patcher.rb#179
|
2020-08-28 00:20:10 +00:00
|
|
|
def save(out_file = T.unsafe(nil), patchelf_compatible: T.unsafe(nil)); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# Get the soname of a shared library.
|
|
|
|
#
|
|
|
|
# @example
|
|
|
|
# patcher = PatchELF::Patcher.new('/bin/ls')
|
|
|
|
# patcher.soname
|
|
|
|
# # [WARN] Entry DT_SONAME not found, not a shared library?
|
|
|
|
# #=> nil
|
|
|
|
# @example
|
|
|
|
# PatchELF::Patcher.new('/lib/x86_64-linux-gnu/libc.so.6').soname
|
|
|
|
# #=> "libc.so.6"
|
|
|
|
# @return [String?] The name.
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/patcher.rb#118
|
2020-07-26 21:04:49 +05:30
|
|
|
def soname; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# Set soname.
|
|
|
|
#
|
|
|
|
# If the input ELF is not a shared library with a soname,
|
|
|
|
# this method will show a warning and has no effect.
|
|
|
|
#
|
|
|
|
# @note This setting will be saved after {#save} being invoked.
|
|
|
|
# @param name [String]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/patcher.rb#128
|
2020-07-26 21:04:49 +05:30
|
|
|
def soname=(name); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# Set all operations related to DT_RUNPATH to use DT_RPATH.
|
|
|
|
#
|
|
|
|
# @return [self]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/patcher.rb#168
|
2020-07-26 21:04:49 +05:30
|
|
|
def use_rpath!; end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2023-12-14 15:34:15 +00:00
|
|
|
# @return [Boolean]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/patcher.rb#228
|
2020-07-26 21:04:49 +05:30
|
|
|
def dirty?; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# source://patchelf//lib/patchelf/patcher.rb#242
|
2020-07-26 21:04:49 +05:30
|
|
|
def dynamic_or_log; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# source://patchelf//lib/patchelf/patcher.rb#202
|
2020-07-26 21:04:49 +05:30
|
|
|
def interpreter_; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# @raise [exception]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/patcher.rb#196
|
2020-08-01 00:32:05 +05:30
|
|
|
def log_or_raise(msg, exception = T.unsafe(nil)); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# @return [Array<String>]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/patcher.rb#210
|
2020-07-26 21:04:49 +05:30
|
|
|
def needed_; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# @return [String?]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/patcher.rb#218
|
2020-08-01 00:32:05 +05:30
|
|
|
def runpath_(rpath_sym = T.unsafe(nil)); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# @return [String?]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/patcher.rb#223
|
2020-07-26 21:04:49 +05:30
|
|
|
def soname_; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# source://patchelf//lib/patchelf/patcher.rb#232
|
2020-07-26 21:04:49 +05:30
|
|
|
def tag_name_or_log(type, log_msg); end
|
|
|
|
end
|
|
|
|
|
2023-12-14 15:34:15 +00:00
|
|
|
# Internal use only.
|
|
|
|
#
|
|
|
|
# For {Patcher} to do patching things and save to file.
|
|
|
|
#
|
|
|
|
# @private
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/saver.rb#16
|
2020-07-26 21:04:49 +05:30
|
|
|
class PatchELF::Saver
|
2023-12-14 15:34:15 +00:00
|
|
|
# Instantiate a {Saver} object.
|
|
|
|
#
|
|
|
|
# @param in_file [String]
|
|
|
|
# @param out_file [String]
|
|
|
|
# @param set [{Symbol => String, Array}]
|
|
|
|
# @return [Saver] a new instance of Saver
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/saver.rb#24
|
2020-07-26 21:04:49 +05:30
|
|
|
def initialize(in_file, out_file, set); end
|
|
|
|
|
2023-12-14 15:34:15 +00:00
|
|
|
# @return [String] Input filename.
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/saver.rb#17
|
2020-07-26 21:04:49 +05:30
|
|
|
def in_file; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# @return [String] Output filename.
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/saver.rb#18
|
2020-07-26 21:04:49 +05:30
|
|
|
def out_file; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# @return [void]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/saver.rb#37
|
2020-07-26 21:04:49 +05:30
|
|
|
def save!; end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2023-12-14 15:34:15 +00:00
|
|
|
# source://patchelf//lib/patchelf/saver.rb#278
|
2020-07-26 21:04:49 +05:30
|
|
|
def dynamic; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# source://patchelf//lib/patchelf/saver.rb#158
|
2020-07-26 21:04:49 +05:30
|
|
|
def expand_dynamic!; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# This can only be used for patching interpreter's name
|
|
|
|
# or set strings in a malloc-ed area.
|
|
|
|
# i.e. NEVER intend to change the string defined in strtab
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/saver.rb#238
|
2020-07-26 21:04:49 +05:30
|
|
|
def inline_patch(off, str); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# Create a temp tag header.
|
|
|
|
#
|
|
|
|
# @return [ELFTools::Structs::ELF_Dyn]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/saver.rb#150
|
2020-07-26 21:04:49 +05:30
|
|
|
def lazy_dyn(sym); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# source://patchelf//lib/patchelf/saver.rb#179
|
2020-07-26 21:04:49 +05:30
|
|
|
def malloc_strtab!; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# source://patchelf//lib/patchelf/saver.rb#88
|
2020-07-26 21:04:49 +05:30
|
|
|
def patch_dynamic; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# source://patchelf//lib/patchelf/saver.rb#53
|
2020-07-26 21:04:49 +05:30
|
|
|
def patch_interpreter; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# source://patchelf//lib/patchelf/saver.rb#121
|
2020-07-26 21:04:49 +05:30
|
|
|
def patch_needed; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# Modify the out_file according to registered patches.
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/saver.rb#243
|
2020-07-26 21:04:49 +05:30
|
|
|
def patch_out(out_file); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# source://patchelf//lib/patchelf/saver.rb#111
|
2020-08-01 00:32:05 +05:30
|
|
|
def patch_runpath(sym = T.unsafe(nil)); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# source://patchelf//lib/patchelf/saver.rb#103
|
2020-07-26 21:04:49 +05:30
|
|
|
def patch_soname; end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# @param str [String]
|
|
|
|
# @yieldparam idx [Integer]
|
|
|
|
# @yieldreturn [void]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/saver.rb#208
|
2020-07-26 21:04:49 +05:30
|
|
|
def reg_str_table(str, &block); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# @return [ELFTools::Sections::Section?]
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/saver.rb#271
|
2020-07-26 21:04:49 +05:30
|
|
|
def section_header(name); end
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# source://patchelf//lib/patchelf/saver.rb#217
|
2020-07-26 21:04:49 +05:30
|
|
|
def strtab_string; end
|
|
|
|
end
|
|
|
|
|
2023-12-14 15:34:15 +00:00
|
|
|
# To mark a not-using tag
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/saver.rb#120
|
2020-07-26 21:04:49 +05:30
|
|
|
PatchELF::Saver::IGNORE = T.let(T.unsafe(nil), Integer)
|
2023-12-14 15:34:15 +00:00
|
|
|
|
|
|
|
# Current gem version.
|
|
|
|
#
|
|
|
|
# source://patchelf//lib/patchelf/version.rb#5
|
2020-07-26 21:04:49 +05:30
|
|
|
PatchELF::VERSION = T.let(T.unsafe(nil), String)
|