Questions tagged [mach-o]

Executable file format utilized by Darwin.

Mach-O is the file format used for executables, shared libraries and object files on OS X and iOS. It supports both single-architecture and multiple-architecture ("fat") binaries.

371 questions
9
votes
0 answers

Indirect symbols in mach-o files

Symbols in mach-o files can be marked as 'indirect' (I in output from nm, defined in the headers using the constant N_INDR). It seems this type of symbol is rarely used in practice (or perhaps has a very specific, limited use). The only example I've…
sjc
  • 418
  • 2
  • 7
9
votes
1 answer

convert MH_EXECUTE to MH_DYLIB (mach-o)

The problem: I have 2 MH_EXECUTE iOS binary files (compiled, no source code). Lets name them binary1 and binary2. I try to switch between them before UIApplicationMain is called! 1 try I successfully do this with binary1 and one dylib. So I try to…
unstable
  • 101
  • 3
9
votes
1 answer

Duplicate Symbol _OBJC_CLASS_$_LoginController

I know this Question has been asked many times before, but none has solved my problem uptill now. I know that this error occurs when you got multiple copies of your file in project. I tried to clean the build, delete any LoginController.m file in…
NightFury
  • 13,436
  • 6
  • 71
  • 120
8
votes
2 answers

Mach-O file LC_FUNCTION_STARTS load command

Does anyone know what the format of the data pointed to by the Mach-O LC_FUNCTION_STARTS command is? The most information I could find is in the loader.h header file: #define LC_FUNCTION_STARTS 0x26 /* compressed table of function start addresses…
Locksleyu
  • 5,192
  • 8
  • 52
  • 77
8
votes
1 answer

Mach-O symbol stubs (IOS)

I am trying to understand how Mach-o files work, and have made a good deal of progress with the online resources available (In particular, the Apple page here:…
Locksleyu
  • 5,192
  • 8
  • 52
  • 77
8
votes
2 answers

Self-modifying code on Darwin 10.15 resulting in "malformed mach-o image"?

I have a program that generates self-modifying code (see https://tigress.wtf/selfModify.html in case you're interested). It runs on x86 Darwin and Linux. On Darwin, I compile with gcc -g -segprot __TEXT rwx rwx self_modifying.c -o…
8
votes
1 answer

What is the significance of a macOS Mach-O dylib LC_ID_DYLIB name, or install_name?

I'm working on developing a macOS dylib framework, developed outside of Xcode, and I'm trying to understand the significance of the install_name option. For example, I can set the LC_ID_DYLIB section name to something more-like what you would find…
Alexander O'Mara
  • 58,688
  • 18
  • 163
  • 171
8
votes
1 answer

Calling getsectiondata from Swift

This question and answer describe how to read data from a Mach-O section with Objective-C on modern OS X/macOS versions: Crash reading bytes from getsectbyname The described answer works. I'm trying to implement the same thing with Swift. I can't…
Juri Pakaste
  • 1,402
  • 10
  • 15
8
votes
1 answer

How libgmalloc work with two level namespaces?

I want to write my own malloc/free functions with debug purposes, documentation says I have to use DYLD_FORCE_FLAT_NAMESPACE together with DYLD_INSERT_LIBRARIES. But at the same time libgmalloc article clearly states: libgmalloc is available in…
dev_null
  • 1,907
  • 1
  • 16
  • 25
8
votes
1 answer

Finding Offsets of Local Symbols in Shared Libraries Programmatically on OS X

I need to find the offset of a local symbol in a shared library on OS X. Local symbol as in non-exported symbol. Therefore dyld("symbol_name") will not work. I can however use nm to find these offsets, for example $ nm…
Johannes Weiss
  • 52,533
  • 16
  • 102
  • 136
7
votes
0 answers

Remove dependent shared library from a dylib?

I know that I can use the -change option of install_name_tool to change the name of a dependent shared library stored in a dylib, but is there a way to remove a dependent shared library, which I believe is a LC_LOAD_DYLIB command, so it won't show…
jfenwick
  • 1,319
  • 15
  • 17
7
votes
1 answer

Mach-O 64-bit format does not support 32-bit absolute addresses. NASM Accessing Array

Running this code off my Mac computer, using command: nasm -f macho64 -o max.a maximum.asm This is the code I am attempting to run on my computer that finds the largest number inside an array. section .data data_items: dd…
Apthos
  • 73
  • 1
  • 6
7
votes
3 answers

duplicate symbols for architecture arm64 (Xcode error)

I deleted all reference to GoogleMobileAdsSDKiOS-7.1 from my project and added 7.4.1. When I ran app on simulator everything works fine but when running on device I get App Mach-O Linker Error. duplicate symbol l017 in: /Users/ib/Desktop/Monster …
Merc
  • 313
  • 1
  • 4
  • 10
7
votes
0 answers

Propagation of rpath in library fails

Short question: Are the rpaths from a LC_RPATH command inside a library passed onto subsequent (and indirect) dynamically loaded libraries? To be more precise: I have libapi.dylib dynamically linked to libloader.dylib which in turn dynamically loads…
phlipsy
  • 2,899
  • 1
  • 21
  • 37
7
votes
4 answers

when i compile an iOS project with using the three part library, i got "Apple Mach-O linker Error"

I've added a library named "*.a" from three part and added its header file in my XCode project. While I compile the project, there are many "Apple Mach-O linker Error". Here the error info: "std::ios_base::failure::~failure()", referenced from: …
Qijin
  • 307
  • 2
  • 13
1 2
3
24 25