Bug 479041 - Executables without RW sections do not trigger debuginfo reading.
Summary: Executables without RW sections do not trigger debuginfo reading.
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: 3.22 GIT
Platform: Other macOS
: NOR normal
Target Milestone: ---
Assignee: Paul Floyd
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-12-26 18:07 UTC by Paul Floyd
Modified: 2023-12-28 10:53 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Floyd 2023-12-26 18:07:23 UTC
It looks like macho can skip having a RW section. For instance

memcheck/tests/supp.c 

objdump -section-headers supp1

supp1:  file format Mach-O 64-bit x86-64

Sections:
Idx Name          Size      Address          Type
  0 __text        0000002f 0000000100000f80 TEXT 
  1 __unwind_info 00000048 0000000100000fb0 DATA

--56886-- di_notify_mmap-2: ./supp1
--56886-- di_notify_mmap-3: is_rx_map 1, is_rw_map 0, is_ro_map 0
--56886-- di_notify_mmap-4: noting details in DebugInfo* at 0x70000087C4A0
--56886-- di_notify_mmap-6: no dinfo loaded ./supp1 (no rx or no rw mapping)
--56886-- di_notify_mmap-0:
--56886-- di_notify_mmap-1: 0x100001000-0x100001fff r--
--56886-- di_notify_mmap-2: ./supp1
--56886-- di_notify_mmap-3: is_rx_map 0, is_rw_map 0, is_ro_map 1
--56886-- di_notify_mmap-4: noting details in DebugInfo* at 0x70000087C4A0
--56886-- di_notify_mmap-6: no dinfo loaded ./supp1 (no rx or no rw mapping)
(next is dyld)

If I add a global variable "int z = 3;" then that is

supp1:  file format Mach-O 64-bit x86-64

Sections:
Idx Name          Size      Address          Type
  0 __text        0000002f 0000000100000f80 TEXT 
  1 __unwind_info 00000048 0000000100000fb0 DATA 
  2 __data        00000004 0000000100001000 DATA
Comment 1 Paul Floyd 2023-12-28 10:53:22 UTC
Plus a few more commits for merge issues.

commit 8e1d13bd11f0064b39896450e15e9d924866c478
Author: Paul Floyd <pjfloyd@wanadoo.fr>
Date:   Thu Dec 28 10:27:18 2023 +0100

    Bug 479041 - Executables without RW sections do not trigger debuginfo reading
    
    The main change is to not assume that there is always 1 and only 1 RW segment.
    Now the rw segment count is obtained from the macho segments.
    
    I've had to make several changes to remove asserts that checked
    that there is always 1 or more rw segments. I don't think that this
    really affects 'normal' C and C++ compiled binaries. There is one
    exp-bbv testcase (x86/million) that is written in assembler and
    was failing until I removed all of the asserts.
    
    There's still a bit more work to do.
    1. Handle fat binaries - are these still a thing (with "apple silicon")?
    2. Use a dynamically sized buffer for the segments rather than just 4k.