-
Notifications
You must be signed in to change notification settings - Fork 568
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
i#1979: steps towards building on MacOS 64-bit #2269
Conversation
shawndenbow
commented
Mar 7, 2017
This commit gets core DR building on MacOS 64-bit. + change error notifications to warning to allow build to continue + define SC_FIELD for 64-bit registers r8-r15 and update references + update dynamorio_mach_dep_syscall to use syscall for 64-bit + update dynamorio_mach_syscall to use syscall for 64-bit + change code referencing eflags to xflags for cross platform compat + misc code fix-ups
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the TLS read change needs to read a 64-bit value
core/arch/x86/x86.asm
Outdated
# ifdef X64 | ||
mov REG_XAX, QWORD [REG_XAX] /* load mach_synch_t->sem */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can stay where it was, shared between the two, via s/DWORD/PTRSZ/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's convenient. Done.
core/arch/x86/x86_shared.asm
Outdated
@@ -42,6 +42,9 @@ | |||
|
|||
#include "../asm_defines.asm" | |||
#include "x86_asm_defines.asm" /* PUSHGPR, POPGPR, etc. */ | |||
#ifdef MACOS | |||
# include <include/syscall_mach.h> /* SYSCALL_NUM_MARKER_MACH */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"" rather than <> as this is our include, not from /usr/include
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
core/unix/os.c
Outdated
ASSERT(is_thread_tls_initialized()); | ||
DOCHECK(1, { | ||
thread_id_t old_tid; | ||
int32_t old_tid; /* can't use thread_id_t since it's 64-bits on x64 */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait -- os_local_state_t.tid is thread_id_t though, so we need to read a pointer-sized value via READ_TLS_SLOT_IMM, rather than changing these locals to ints. Maybe have a READ_TLS_TIDSZ_SLOT_IMM or sthg.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. Ok, for this case I think using a pointer-sized w/ READ_TLS_SLOT_IMM works. That's mentioned in the comments too where the macro is defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you'll read too much for Linux: pid_t is 32 bits even for x86_64. Do you mean you'll read extra into a local and then truncate it (and assume little-endian)?
core/unix/signal.c
Outdated
@@ -2794,11 +2794,9 @@ fixup_rtframe_pointers(dcontext_t *dcontext, int sig, | |||
# endif | |||
/* 32-bit kernel copies to aligned buf first */ | |||
IF_X64(ASSERT(ALIGNED(f_new->uc.uc_mcontext.fpstate, 16))); | |||
#elif defined(MACOS) | |||
# ifndef X64 | |||
#elif defined(MACOS) && !defined(X64) /* XXX: macos 64-bit support needs work */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should X64 have an ASSERT_NOT_IMPLEMENTED?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
core/unix/signal.c
Outdated
@@ -2964,7 +2962,7 @@ copy_frame_to_stack(dcontext_t *dcontext, int sig, sigframe_rt_t *frame, byte *s | |||
} | |||
#endif /* X86 && LINUX */ | |||
|
|||
#ifdef MACOS | |||
#if defined(MACOS) && !defined(X64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should X64 have an ASSERT_NOT_IMPLEMENTED?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
core/unix/os.c
Outdated
ASSERT(old_tid == old); | ||
}); | ||
WRITE_TLS_INT_SLOT_IMM(TLS_THREAD_ID_OFFSET, new_tid); | ||
WRITE_TLS_SLOT_IMM(TLS_THREAD_ID_OFFSET, new_tid); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will overflow for Linux x64 where pid_t (== thread_id_t) is 32 bits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
core/unix/os.c
Outdated
int32_t old_tid; /* can't use thread_id_t since it's 64-bits on x64 */ | ||
READ_TLS_INT_SLOT_IMM(TLS_THREAD_ID_OFFSET, old_tid); | ||
ptr_int_t old_tid; | ||
READ_TLS_SLOT_IMM(TLS_THREAD_ID_OFFSET, old_tid); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will read the adjacent field (or maybe padding, did not check the struct): it would have to be truncated (or have a custom READ_TLS_SLOT_TIDSZ_IMM as suggested in original comment, or have series of ifdefs or sizeof checks here).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok...I wasn't thinking on this one. Done.
A series of small changes to build with XCode 10.1 64-bit: + Updates -max_supported_os_version on Mac to 18. + Updates 64-bit Mac frame field. + Removes , from runtime options in template defines. + Removes 32-bit-only tests from the OSX label list for 64-bit. + Increases the core's preferred base to 0x1'71000000 to stay above the default 0x1' _PAGEZERO. + Adds missing DECL_EXTERNs in mangle_suspend and mangle_asynch tests. + Adds missing GLOBAL_REFs in common.decode test. + Re-defines sigcontext_t and uc_mcontext in tools.h to match this toolchain. + Adds 64-bit libelftc.a and libdwarf.a Mach-O libraries along with instructions on how they were built. + Adds -mmacosx-version-min=10.9 to drcachesim to match core/. + Fixes a format string warning in drcachesim. Includes a number of similar small changes from Shawn Denbow's first 2 commits on the project-mac64 branch in PR #2269 and PR #2273, updated for clang-format: + Move -vm_base above 4GB since __PAGEZERO takes up first 4GB by default + Increase MEMQUERY_INTERNAL_DATA_LEN + Update Mach-O parsing to check for LC_SEGMENT_64 + Change error notifications to warning to allow build to continue + Define SC_FIELD for 64-bit registers r8-r15 and update references + Update dynamorio_mach_dep_syscall to use syscall for 64-bit + Update dynamorio_mach_syscall to use syscall for 64-bit + Change code referencing eflags to xflags for cross platform compat + Misc code fix-ups Issue: #1979
A series of small changes to build with XCode 10.1 64-bit (from PR #3514 on project-mac64): + Updates -max_supported_os_version on Mac to 18. + Updates 64-bit Mac frame field. + Removes , from runtime options in template defines. + Removes 32-bit-only tests from the OSX label list for 64-bit. + Increases the core's preferred base to 0x1'71000000 to stay above the default 0x1' _PAGEZERO. + Adds missing DECL_EXTERNs in mangle_suspend and mangle_asynch tests. + Adds missing GLOBAL_REFs in common.decode test. + Re-defines sigcontext_t and uc_mcontext in tools.h to match this toolchain. + Adds 64-bit libelftc.a and libdwarf.a Mach-O libraries along with instructions on how they were built. + Adds -mmacosx-version-min=10.9 to drcachesim to match core/. + Fixes a format string warning in drcachesim. Includes a number of similar small changes from Shawn Denbow's first 2 commits on the project-mac64 branch in PR #2269 and PR #2273, updated for clang-format: + Move -vm_base above 4GB since __PAGEZERO takes up first 4GB by default + Increase MEMQUERY_INTERNAL_DATA_LEN + Update Mach-O parsing to check for LC_SEGMENT_64 + Change error notifications to warning to allow build to continue + Define SC_FIELD for 64-bit registers r8-r15 and update references + Update dynamorio_mach_dep_syscall to use syscall for 64-bit + Update dynamorio_mach_syscall to use syscall for 64-bit + Change code referencing eflags to xflags for cross platform compat + Misc code fix-ups Issue: #1979
A series of small changes to build with XCode 10.1 64-bit (from PR #3514 on project-mac64): + Updates -max_supported_os_version on Mac to 18. + Updates 64-bit Mac frame field. + Removes , from runtime options in template defines. + Removes 32-bit-only tests from the OSX label list for 64-bit. + Increases the core's preferred base to 0x1'71000000 to stay above the default 0x1' _PAGEZERO. + Adds missing DECL_EXTERNs in mangle_suspend and mangle_asynch tests. + Adds missing GLOBAL_REFs in common.decode test. + Re-defines sigcontext_t and uc_mcontext in tools.h to match this toolchain. + Adds 64-bit libelftc.a and libdwarf.a Mach-O libraries along with instructions on how they were built. + Adds -mmacosx-version-min=10.9 to drcachesim to match core/. + Fixes a format string warning in drcachesim. Includes a number of similar small changes from Shawn Denbow's first 2 commits on the project-mac64 branch in PR #2269 and PR #2273, updated for clang-format: + Move -vm_base above 4GB since __PAGEZERO takes up first 4GB by default + Increase MEMQUERY_INTERNAL_DATA_LEN + Update Mach-O parsing to check for LC_SEGMENT_64 + Change error notifications to warning to allow build to continue + Define SC_FIELD for 64-bit registers r8-r15 and update references + Update dynamorio_mach_dep_syscall to use syscall for 64-bit + Update dynamorio_mach_syscall to use syscall for 64-bit + Change code referencing eflags to xflags for cross platform compat + Misc code fix-ups Issue: #1979