-
Notifications
You must be signed in to change notification settings - Fork 558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
suggestion: build without PIE on macOS, if possible? #928
Comments
This sounds reasonable to add to the |
Preliminary searching suggests both GCC and Clang support |
I tried adding a long pile of no-pie flags and still couldn't get macOS to build me a version without PIE. diff --git a/desktop_version/CMakeLists.txt b/desktop_version/CMakeLists.txt
index 7f181ef..2615b15 100644
--- a/desktop_version/CMakeLists.txt
+++ b/desktop_version/CMakeLists.txt
@@ -439,6 +439,11 @@ else()
endif()
endif()
+if(NOT MSVC)
+ target_compile_options(VVVVVV PRIVATE -no-pie -fno-pie -fno-PIE -Wl,-no_pie)
+ target_link_libraries(VVVVVV -no-pie -fno-pie)
+endif()
+
# Yes, more Apple Crap
if(APPLE)
find_library(FOUNDATION NAMES Foundation) Some particularly damning compiler spew (thanks, lld!):
So maybe there is not really a good solution here in the long run. |
Yeah, it seems to me that macOS is strictly enforcing PIE in the future for whatever reason. |
An alternative, possibly-silly suggestion to help out future autosplitters on platforms where memory scanning is inevitable, and thus the diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h
index 6dc2517..904b19e 100644
--- a/desktop_version/src/Game.h
+++ b/desktop_version/src/Game.h
@@ -133,6 +133,8 @@ struct CustomLevelStat
class Game
{
public:
+ char magic[16];
+
void init(void);
diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp
index 847044d..e124392 100644
--- a/desktop_version/src/Game.cpp
+++ b/desktop_version/src/Game.cpp
@@ -158,6 +158,8 @@ end:
void Game::init(void)
{
+ SDL_strlcpy(magic, "[vVvVvV]game", 16);
+
roomx = 0;
roomy = 0;
prevroomx = 0; It's likely only one marker string is necessary because you can rely on relative offsets based on If this seems like an acceptable I'll make sure that memory string is actually unique and open a PR. |
Yes, this is acceptable. It's something I was considering too. Though, use |
The `-addresses` command-line option added in 64be99d helps autosplitters on platforms where VVVVVV is not built as a position-independent executable. macOS has made it increasingly difficult, or impossible, to build binaries without PIE. Adding an obvious string to search for will help tools that need to deal with versions of VVVVVV built with PIE. The bytestring to search for is `[vVvVvV]game`, followed by four null bytes (to avoid finding it in the program code section). This identifies the beginning of the game object; addresses to other objects can be figured out by relative offsets printed by `-addresses`, since ASLR can only change where the globals begin. Partially fixes TerryCavanagh#928; it may still be advisable to figure out how to explicitly disable PIE on Windows/Linux.
oh, the commit message closed the issue anyway. oops |
lmao |
Here are some things I found that may help. I do not have macOS, so I can't test any of these. According to this 2-year-old blog post, LLDB will disable ASLR by default. How it does this I do not know. Might be worth looking into. In the latest CMake version, there is a |
lldb starts the application via |
The Linux and Windows builds of VVVVVV are not position-independent executables because the compilers used for these releases do not enable PIE by default. This allows autosplitters on Linux and Windows to hardcode relevant memory addresses for different versions (or since 64be99d, run the program with
-addresses
to prevent needing to hardcode future versions).macOS's compiler enables PIE by default, thus enabling address space layout randomization, which resulted in me making some wild implementation-specific memory searching code.
-addresses
won't address the issue for macOS because the addresses will be different every time the program starts.A flag to disable PIE for Linux builds may help in the future as well; if the build environment ends up being updated from CentOS 7, generally any newer Linux distro will enable PIE by default.
(I am posting this issue in the hopes that someone who understands CMake and Clang options more than me will consider updating the build scripts; I am attempting to come up with a solution on my own as well, though.)
The text was updated successfully, but these errors were encountered: