# Printing rpaths with objdump

DevFeed: [Printing rpaths with objdump](<https://devfeed.tech/articles/printing-rpaths-with-objdump-25409.md>)

Original publisher: [Read original article](<https://smileykeith.com/2022/03/16/objdump-rpaths/>)

Author: Keith Smiley

Published: 2022-03-16T17:00:00Z

Content type: tutorial

Language: en

Sources: [Keith Smiley](<https://devfeed.tech/sources/keith-smiley.md>)

Topics: [LLVM](<https://devfeed.tech/topics/llvm.md>), [macOS](<https://devfeed.tech/topics/macos.md>), [Xcode](<https://devfeed.tech/topics/xcode.md>), [Swift](<https://devfeed.tech/topics/swift.md>), [debugging](<https://devfeed.tech/topics/debugging.md>), [Tooling](<https://devfeed.tech/topics/tooling.md>)

Tags: [binaries](<https://devfeed.tech/tags/binaries.md>), [commands](<https://devfeed.tech/tags/commands.md>), [debugging](<https://devfeed.tech/tags/debugging.md>), [llvm](<https://devfeed.tech/tags/llvm.md>), [macos](<https://devfeed.tech/tags/macos.md>), [swift](<https://devfeed.tech/tags/swift.md>), [xcode](<https://devfeed.tech/tags/xcode.md>)

## AI overview

The article explains how to inspect runtime library search paths in Mach-O binaries. It compares a verbose otool pipeline with the more concise LLVM objdump --macho --rpaths command, introduced with LLVM 13 and Xcode 13.3 on macOS.

## Source excerpt

MachO binaries contain load commands to indicate to dyld where it should search for the libraries the binary depends on. These paths are often useful to inspect when debugging why your binary isn't discovering the libraries you'd expect. Previously you could discover these with: % otool -l `xcrun -f swiftc` \ | grep -A2 LC_RPATH \ | grep "^\s*path" \ | cut -d " " -f 11 @executable_path/../lib/swift/macosx @executable_path/../lib/swift/macosx This example is quite verbose and fragile for such a common action, so recently I committed a change to add an easier option with LLVM's objdump. This change shipped with LLVM 13 or Xcode 13.3 on macOS, allowing you to run: % objdump --macho --rpaths `xcrun -f swiftc` /Applications/Xcode-13.3.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc: @executable_path/../lib/swift/macosx This is much more succinct and memorable, but also has slightly different output. This is because objdump automatically detects the current machine's architecture, and only prints the rpaths for that slice of the fat binary. It also outputs the path of the binary being run on, which you can disable with --no-leading-headers. Hopefully you find this as useful as I do!