Skip to content

Commit

Permalink
i#1979 Mac64: 64-bit Mach-O drsyms support
Browse files Browse the repository at this point in the history
Adds 64-bit Mach-O support to drsyms, which consists simply of looking for
LC_SEGMENT_64 in addition to LC_SEGMENT in drsyms_macho.c and in a
repatched version of libelftc.

Issue: #1979
  • Loading branch information
derekbruening committed Sep 16, 2019
1 parent 030ed9b commit cfe1c55
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ext/drsyms/drsyms_macho.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ find_load_base(byte *map_base, size_t *load_size)
cmd = (struct load_command *)(hdr + 1);
cmd_stop = (struct load_command *)((byte *)cmd + hdr->sizeofcmds);
while (cmd < cmd_stop) {
if (cmd->cmd == LC_SEGMENT) {
if (cmd->cmd == LC_SEGMENT || cmd->cmd == LC_SEGMENT_64) {
segment_command_t *seg = (segment_command_t *)cmd;
if (!found_seg) {
found_seg = true;
Expand Down Expand Up @@ -371,7 +371,7 @@ drsym_obj_mod_init_pre(byte *map_base, size_t map_size)
cmd = (struct load_command *)(hdr + 1);
cmd_stop = (struct load_command *)((char *)cmd + hdr->sizeofcmds);
while (cmd < cmd_stop) {
if (cmd->cmd == LC_SEGMENT) {
if (cmd->cmd == LC_SEGMENT || cmd->cmd == LC_SEGMENT_64) {
segment_command_t *seg = (segment_command_t *)cmd;
section_t *sec, *sec_stop;
sec_stop = (section_t *)((char *)seg + seg->cmdsize);
Expand Down
Binary file modified ext/drsyms/libelftc-macho/lib64/libdwarf.a
Binary file not shown.
4 changes: 2 additions & 2 deletions ext/drsyms/libelftc-macho/libelftc-macho.patch
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ Index: libdwarf/libdwarf_macho_init.c
+ cmd_stop = (struct load_command *)((char *)cmd + hdr->sizeofcmds);
+ }
+ while (cmd < cmd_stop) {
+ if (cmd->cmd == LC_SEGMENT) {
+ if (cmd->cmd == LC_SEGMENT || cmd->cmd == LC_SEGMENT_64) {
+ if (is_64) {
+ struct segment_command_64 *seg64 = (struct segment_command_64 *) cmd;
+ struct section_64 *sec64 = (struct section_64 *)(seg64 + 1);
Expand Down Expand Up @@ -547,7 +547,7 @@ Index: libdwarf/libdwarf_macho_init.c
+ else
+ cmd = (struct load_command *)(hdr + 1);
+ while (cmd < cmd_stop) {
+ if (cmd->cmd == LC_SEGMENT) {
+ if (cmd->cmd == LC_SEGMENT || cmd->cmd == LC_SEGMENT_64) {
+ if (is_64) {
+ struct segment_command_64 *seg64 = (struct segment_command_64 *) cmd;
+ struct section_64 *sec64 = (struct section_64 *)(seg64 + 1);
Expand Down

0 comments on commit cfe1c55

Please sign in to comment.