Skip to content

in nontrivial programs, malloc/calloc are already called before "main" is invoked #7

@timo

Description

@timo

For example, here's a traceback at a random spot before main that calls calloc

#1  0x00007ffff7fdd3d4 in _dl_new_object (
    realname=realname@entry=0x7ffff7fc93e0 "/lib64/librt.so.1", 
    libname=libname@entry=0x7ffff77472db "librt.so.1", type=type@entry=1, 
    loader=loader@entry=0x7ffff7fc8000, mode=mode@entry=0, nsid=nsid@entry=0) at dl-object.c:89
#2  0x00007ffff7fd8857 in _dl_map_object_from_fd (name=name@entry=0x7ffff77472db "librt.so.1", 
    origname=origname@entry=0x0, fd=3, fbp=fbp@entry=0x7fffffffd780, 
    realname=0x7ffff7fc93e0 "/lib64/librt.so.1", loader=loader@entry=0x7ffff7fc8000, l_type=1, 
    mode=0, stack_endp=0x7fffffffd778, nsid=0) at dl-load.c:999
#3  0x00007ffff7fda92b in _dl_map_object (loader=0x7ffff7fc8000, name=0x7ffff77472db "librt.so.1", 
    type=1, trace_mode=0, mode=<optimized out>, nsid=<optimized out>) at dl-load.c:2230
#4  0x00007ffff7fdf485 in openaux (a=a@entry=0x7fffffffdd90) at dl-deps.c:64
#5  0x00007ffff7feccfe in _dl_catch_exception (exception=exception@entry=0x7fffffffdd70, 
    operate=operate@entry=0x7ffff7fdf450 <openaux>, args=args@entry=0x7fffffffdd90)
    at dl-error-skeleton.c:208
#6  0x00007ffff7fdf8c3 in _dl_map_object_deps (map=map@entry=0x7ffff7ffe140, 
    preloads=<optimized out>, npreloads=npreloads@entry=0, trace_mode=trace_mode@entry=0, 
    open_mode=open_mode@entry=0) at dl-deps.c:248
#7  0x00007ffff7fd4e91 in dl_main (phdr=<optimized out>, phnum=<optimized out>, 
    user_entry=<optimized out>, auxv=<optimized out>) at rtld.c:1799
#8  0x00007ffff7febc8b in _dl_sysdep_start (start_argptr=start_argptr@entry=0x7fffffffe520, 
    dl_main=dl_main@entry=0x7ffff7fd3450 <dl_main>) at ../elf/dl-sysdep.c:252
#9  0x00007ffff7fd2fac in _dl_start_final (arg=0x7fffffffe520) at rtld.c:447
#10 _dl_start (arg=0x7fffffffe520) at rtld.c:537
#11 0x00007ffff7fd2118 in _start () from /lib64/ld-linux-x86-64.so.2

https://github.com/FooBarWidget/heap_dumper_visualizer - this tool uses objdump to find the offset of main_arena in libc.so and then finds libc.so in the /proc/pid/maps and bases all its calculations on that, but something in there is incompatible with latest glibc

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions