summaryrefslogtreecommitdiffstats
path: root/vendor/object/src/write
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/object/src/write')
-rw-r--r--vendor/object/src/write/coff.rs2
-rw-r--r--vendor/object/src/write/elf/object.rs2
-rw-r--r--vendor/object/src/write/macho.rs16
-rw-r--r--vendor/object/src/write/mod.rs5
-rw-r--r--vendor/object/src/write/xcoff.rs2
5 files changed, 22 insertions, 5 deletions
diff --git a/vendor/object/src/write/coff.rs b/vendor/object/src/write/coff.rs
index d2f7ccc64..2277a08e2 100644
--- a/vendor/object/src/write/coff.rs
+++ b/vendor/object/src/write/coff.rs
@@ -83,7 +83,7 @@ impl<'a> Object<'a> {
name
}
- pub(crate) fn coff_fixup_relocation(&mut self, mut relocation: &mut Relocation) -> i64 {
+ pub(crate) fn coff_fixup_relocation(&mut self, relocation: &mut Relocation) -> i64 {
if relocation.kind == RelocationKind::GotRelative {
// Use a stub symbol for the relocation instead.
// This isn't really a GOT, but it's a similar purpose.
diff --git a/vendor/object/src/write/elf/object.rs b/vendor/object/src/write/elf/object.rs
index acc820c9e..421d23a86 100644
--- a/vendor/object/src/write/elf/object.rs
+++ b/vendor/object/src/write/elf/object.rs
@@ -152,7 +152,7 @@ impl<'a> Object<'a> {
})
}
- pub(crate) fn elf_fixup_relocation(&mut self, mut relocation: &mut Relocation) -> Result<i64> {
+ pub(crate) fn elf_fixup_relocation(&mut self, relocation: &mut Relocation) -> Result<i64> {
// Return true if we should use a section symbol to avoid preemption.
fn want_section_symbol(relocation: &Relocation, symbol: &Symbol) -> bool {
if symbol.scope != SymbolScope::Dynamic {
diff --git a/vendor/object/src/write/macho.rs b/vendor/object/src/write/macho.rs
index e3ce55bb4..05c376cf9 100644
--- a/vendor/object/src/write/macho.rs
+++ b/vendor/object/src/write/macho.rs
@@ -48,6 +48,14 @@ impl MachOBuildVersion {
// Public methods.
impl<'a> Object<'a> {
+ /// Specify the Mach-O CPU subtype.
+ ///
+ /// Requires `feature = "macho"`.
+ #[inline]
+ pub fn set_macho_cpu_subtype(&mut self, cpu_subtype: u32) {
+ self.macho_cpu_subtype = Some(cpu_subtype);
+ }
+
/// Specify information for a Mach-O `LC_BUILD_VERSION` command.
///
/// Requires `feature = "macho"`.
@@ -243,7 +251,7 @@ impl<'a> Object<'a> {
init_symbol_id
}
- pub(crate) fn macho_fixup_relocation(&mut self, mut relocation: &mut Relocation) -> i64 {
+ pub(crate) fn macho_fixup_relocation(&mut self, relocation: &mut Relocation) -> i64 {
let constant = match relocation.kind {
// AArch64Call relocations have special handling for the addend, so don't adjust it
RelocationKind::Relative if relocation.encoding == RelocationEncoding::AArch64Call => 0,
@@ -385,7 +393,7 @@ impl<'a> Object<'a> {
.map_err(|_| Error(String::from("Cannot allocate buffer")))?;
// Write file header.
- let (cputype, cpusubtype) = match self.architecture {
+ let (cputype, mut cpusubtype) = match self.architecture {
Architecture::Arm => (macho::CPU_TYPE_ARM, macho::CPU_SUBTYPE_ARM_ALL),
Architecture::Aarch64 => (macho::CPU_TYPE_ARM64, macho::CPU_SUBTYPE_ARM64_ALL),
Architecture::Aarch64_Ilp32 => {
@@ -403,6 +411,10 @@ impl<'a> Object<'a> {
}
};
+ if let Some(cpu_subtype) = self.macho_cpu_subtype {
+ cpusubtype = cpu_subtype;
+ }
+
let flags = match self.flags {
FileFlags::MachO { flags } => flags,
_ => 0,
diff --git a/vendor/object/src/write/mod.rs b/vendor/object/src/write/mod.rs
index 711ff16d2..15ca29d79 100644
--- a/vendor/object/src/write/mod.rs
+++ b/vendor/object/src/write/mod.rs
@@ -75,6 +75,9 @@ pub struct Object<'a> {
pub mangling: Mangling,
/// Mach-O "_tlv_bootstrap" symbol.
tlv_bootstrap: Option<SymbolId>,
+ /// Mach-O CPU subtype.
+ #[cfg(feature = "macho")]
+ macho_cpu_subtype: Option<u32>,
#[cfg(feature = "macho")]
macho_build_version: Option<MachOBuildVersion>,
}
@@ -96,6 +99,8 @@ impl<'a> Object<'a> {
mangling: Mangling::default(format, architecture),
tlv_bootstrap: None,
#[cfg(feature = "macho")]
+ macho_cpu_subtype: None,
+ #[cfg(feature = "macho")]
macho_build_version: None,
}
}
diff --git a/vendor/object/src/write/xcoff.rs b/vendor/object/src/write/xcoff.rs
index 6c9a80384..fc58886ed 100644
--- a/vendor/object/src/write/xcoff.rs
+++ b/vendor/object/src/write/xcoff.rs
@@ -66,7 +66,7 @@ impl<'a> Object<'a> {
}
}
- pub(crate) fn xcoff_fixup_relocation(&mut self, mut relocation: &mut Relocation) -> i64 {
+ pub(crate) fn xcoff_fixup_relocation(&mut self, relocation: &mut Relocation) -> i64 {
let constant = match relocation.kind {
RelocationKind::Relative => relocation.addend + 4,
_ => relocation.addend,