Commit 1f418de3 authored by Nico Weber's avatar Nico Weber Committed by Commit Bot

mac: Fix bug in generate_breakpad_symbols.py exposed by rpath stack removal.

The framework depends on libfoo.dylib, and when we symbolize this dependency,
we use dirname(libfoo.dylib) -> '' as @loader_path, turning the rpath
@loader_path/. into the absolute path /.

Call realname() on the file before calling dirname to fix this, and to
fix a second (latent) bug where the rpaths should be relative to the
symlink targets, not to symlinks.

(I think this was always broken, but harmless before I made
GetSharedLibraryDependenciesMac() error out on resolving failures, and
harmless in practice since the framework itself symbolized itself and
its deps fine, just resolving the deps of the deps would silently fail
before I made it fail loudly.)

Bug: 853716
Change-Id: I519f786f785bcae8b5d64edc8ff1a883edba5c72
Reviewed-on: https://chromium-review.googlesource.com/1104393Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568018}
parent 05159fe7
...@@ -109,7 +109,15 @@ def GetSharedLibraryDependenciesMac(binary, exe_path): ...@@ -109,7 +109,15 @@ def GetSharedLibraryDependenciesMac(binary, exe_path):
"""Return absolute paths to all shared library dependecies of the binary. """Return absolute paths to all shared library dependecies of the binary.
This implementation assumes that we're running on a Mac system.""" This implementation assumes that we're running on a Mac system."""
loader_path = os.path.dirname(binary) # realpath() serves two purposes:
# 1. If an executable is linked against a framework, it links against
# Framework.framework/Framework, which is a symlink to
# Framework.framework/Framework/Versions/A/Framework. rpaths are relative
# to the real location, so resolving the symlink is important.
# 2. It converts binary to an absolute path. If binary is just
# "foo.dylib" in the current directory, dirname() would return an empty
# string, causing "@loader_path/foo" to incorrectly expand to "/foo".
loader_path = os.path.dirname(os.path.realpath(binary))
env = os.environ.copy() env = os.environ.copy()
developer_dir = GetDeveloperDirMac() developer_dir = GetDeveloperDirMac()
if developer_dir: if developer_dir:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment