-
Notifications
You must be signed in to change notification settings - Fork 62
Description
(Related to my sampling profiler project...)
I am compiling a 68k application and attempting to profile it, which means I need to compile with debugging information. I discovered that using -Wl,-gc-sections results in invalid debugging information, which I think is due an issue where gcc removes sections of code but not its debugging information, resulting in overlapping debugging info that trips up debugging tools like llvm-addr2line. (Note: I am not 100% sure that's actually what's going wrong, but that's my understanding given the research I've done.)
I've built my application with -Wl,--mac-single and without -Wl,-gc-sections and had it successfully run on a Macintosh SE/30 and an emulated Macintosh II using Mini vMac. However, when I run the same application on a Macintosh Classic II, it will crash as soon as the application launches. All of these systems are running System 7.1.
Here's some info about the crash. First MacsBug will pop up reporting a user break at Retro68ApplyRelocations+000E0:
+000E0 004F6AFC *MOVEQ #$03,D1
+000E2 004F6AFE AND.L D7.D1
+000E4 004F6B00 ADD.L D1,D1
If I keep tell it to continue (i.e. g), it will repeatedly stop at that address several more times. And then eventually it will crash with an illegal instruction error:
0000002E *DC.W $957E
00000030 NEGX.L -(A0)
00000032 MOVE.L D4, -(A3)
I gather the issue is that at some point PC jumped to a very low point in memory. In a few cases I've gotten a similar crash due to a bus error, but PC was still at an absurd address.
Is this a bug in Retro68ApplyRelocations? Or perhaps there's some reason why -Wl,-gc-sections is required for Retro68ApplyRelocations to function correctly? Either way, why does the app work on an SE/30 but not a Classic II?
(I'm also looking for other ways of getting debugging information to work correctly when compiling with -Wl,-gc-sections but so far without success.)