Jan Vrany e855469f9d Revert "gdb: change blockvector::contains() to handle blockvectors with "holes""
This reverts commit cc1fc6af41, since it
causes a number of regressions that seem not to be easily fixable.

The problem lies in existence of "freestanding" code, a code that is
part of a CU but does not have any block associated with it. Consider
following program:

    __asm__(
      ".type foo,@function   \n"
      "foo:                  \n"
      "  mov %rdi, %rax      \n"
      "  ret                 \n"
    );

    static int foo(int i);

    int main(int argc, char **argv) {
      return foo(argc);
    }

When compiled, the foo function has no block of itself:

    Blockvector:

    no map

    block #000, object at 0x55978957b510, 1 symbols in 0x1129..0x1148
     int main(int, char **); block object 0x55978957b380, 0x112d..0x1148 section .text
      block #001, object at 0x55978957b470 under 0x55978957b510, 2 symbols in 0x1129..0x1148
       typedef int int;
       typedef char char;
        block #002, object at 0x55978957b380 under 0x55978957b470, 2 symbols in 0x112d..0x1148, function main
         int argc; computed at runtime
         char **argv; computed at runtime

In this case lookup(0x1129) returns static block and, because of the
change in cc1fc6af4, contains(0x1129) which is wrong.

Such "freestanding" code is perhaps not common but it does exist,
especially in system code. In fact the regressions were at least in part
caused by such "freestanding" code in glibc (libc_sigaction.c).

The whole idea of commit cc1fc6af4 was to handle "holes" in CUs, a case
where one CU spans over multiple disjoint regions, possibly interleaved
with other CUs. Consider somewhat extreme case with two CUs:

    /* hole-1.c */
    int give_me_zero ();

    int
    main ()
    {
      return give_me_zero ();
    }

    /* hole-2.c */
        int __attribute__ ((section (".text_give_me_one"))) __attribute__((noinline))
    baz () { return 42; }

    __asm__(
      ".section  .text_give_me_one,\"ax\",@progbits\n"
      ".type foo,@function         \n"
      "foo:                        \n"
            "  mov %rdi, %rax      \n"
            "  ret                 \n"
            "  nop                 \n"
            "  nop                 \n"
            "  nop                 \n"
    );
    int __attribute__ ((section (".text_give_me_one"))) __attribute__((noinline))
    give_me_one ()
    {
      return 1;
    }

    __asm__(
      ".section  .text_give_me_zero,\"ax\",@progbits\n"
      "bar:                        \n"
            "  jmp give_me_one     \n"
            "  nop                 \n"
            "  nop                 \n"
            "  nop                 \n"
    );
    int __attribute__ ((section (".text_give_me_zero")))
    give_me_zero ()
    {
      extern int bar();
      return give_me_one() - 1;
    }

This when compiled with a carefully crafted linker script to force code
at certain positions, creates following layout:

   0x080000..0x080007   # "freestanding" bar from hole-2.c
   0x080008..0x080016   # give_me_zero() from hole-2.c
   0x080109..0x080114   # main from hole-1.c
   0xf00000..0xf0000b   # baz() from hole-2.c
   0xf0000b..0xf00011   # "freestanding" foo from hole-2.
   0xf0000b..0xf0001c   # gice_me_one() from hole-2.

The block vector for hole-1.c looks:

    Blockvector:

    no map

    block #000, object at 0x555a5d85fb90, 1 symbols in 0x80109..0x80114
     int main(void); block object 0x555a5d85faa0, 0x80109..0x80114 section .text
      block #001, object at 0x555a5d85faf0 under 0x555a5d85fb90, 1 symbols in 0x80109..0x80114
       typedef int int;
        block #002, object at 0x555a5d85faa0 under 0x555a5d85faf0, 0 symbols in 0x80109..0x80114, function main

And for hole-2.c:

    Blockvector:

    map
      0x0 -> 0x0
      0x80008 -> 0x555a5d85ff50
      0x80016 -> 0x0
      0xf00000 -> 0x555a5d860280
      0xf0000b -> 0x0
      0xf00012 -> 0x555a5d860110
      0xf0001d -> 0x0

    block #000, object at 0x555a5d8603b0, 3 symbols in 0x80008..0xf0001d
     int give_me_zero(void); block object 0x555a5d85ff50, 0x80008..0x80016 section .text
     int give_me_one(void); block object 0x555a5d860110, 0xf00012..0xf0001d section .text
     int baz(void); block object 0x555a5d860280, 0xf00000..0xf0000b section .text
      block #001, object at 0x555a5d8602d0 under 0x555a5d8603b0, 1 symbols in 0x80008..0xf0001d
       typedef int int;
        block #002, object at 0x555a5d85ff50 under 0x555a5d8602d0, 0 symbols in 0x80008..0x80016, function give_me_zero
        block #003, object at 0x555a5d860280 under 0x555a5d8602d0, 0 symbols in 0xf00000..0xf0000b, function baz
        block #004, object at 0x555a5d860110 under 0x555a5d8602d0, 0 symbols in 0xf00012..0xf0001d, function give_me_one

Note that despite the fact "freestanding" bar belongs to hole-2.c, the
corresponding CU's global and static blocks start at 0x80008! Looking
at DWARF for the second program, it looks like that the compiler (GCC 15)
did not record the presence of "freestanding" code:

    <0><71>: Abbrev Number: 1 (DW_TAG_compile_unit)
        <72>   DW_AT_producer    : (indirect string, offset: 0): GNU C23 15.2.0 -mtune=generic -march=x86-64 -g -fasynchronous-unwind-tables
        <76>   DW_AT_language    : 29   (C11)
        <77>   Unknown AT value: 90: 3
        <78>   Unknown AT value: 91: 0x31647
        <7c>   DW_AT_name        : (indirect line string, offset: 0x2d): hole-2.c
        <80>   DW_AT_comp_dir    : (indirect line string, offset: 0): test_programs
        <84>   DW_AT_ranges      : 0xc
        <88>   DW_AT_low_pc      : 0
        <90>   DW_AT_stmt_list   : 0x51

and corresponding part of .debug_aranges:

      Length:                   76
      Version:                  2
      Offset into .debug_info:  0x65
      Pointer Size:             8
      Segment Size:             0

        Address            Length
        0000000000f00000 000000000000000b
        0000000000f00012 000000000000000b
        0000000000080008 000000000000000e
        0000000000000000 0000000000000000

Thiago suggested to use minsymbols to tell whether or a CU contains
given address. I do not think this would work reliably as minsymbols do
no know to which CU they belong. In slightly more complicated case of
interleaved CUs it does not seem to be possible to tell for sure to which
one a given minsymbol belongs.

Moreover, Tom suggested that the comment in find_compunit_symtab_for_pc_sect
(which led to cc1fc6af4) may be outdated [2].

Given all that, I'm just reverting the change.

[1]: https://sourceware.org/bugzilla/show_bug.cgi?id=33679#c13
[2]: https://inbox.sourceware.org/gdb-patches/87cy6xzd3j.fsf@tromey.com/

Approved-By: Tom Tromey <tom@tromey.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33679
2025-12-22 12:54:52 +00:00
2025-12-21 00:00:08 +00:00
2025-11-03 10:59:50 +10:30
2025-07-13 08:35:45 +01:00
2025-12-10 00:25:20 +01:00
2025-12-18 11:50:08 -07:00
2025-12-09 20:17:41 +10:30
2025-11-03 13:01:42 +10:30
2023-08-12 10:27:57 +09:30
2025-11-03 10:59:50 +10:30
2025-12-05 14:23:30 +00:00
2025-11-03 10:59:50 +10:30
2025-02-28 16:06:25 +00:00
2025-07-13 08:35:45 +01:00
2025-11-03 09:53:04 +00:00
2025-11-03 09:53:04 +00:00
2025-11-03 09:53:04 +00:00
2025-10-02 07:42:18 +08:00
2025-10-02 07:42:18 +08:00
2025-09-07 04:06:01 +01:00

		   README for GNU development tools

This directory contains various GNU compilers, assemblers, linkers, 
debuggers, etc., plus their support routines, definitions, and documentation.

If you are receiving this as part of a GDB release, see the file gdb/README.
If with a binutils release, see binutils/README, and so on. That'll give you
info about this package -- supported targets, how to use it, how to report
bugs, etc.

It is now possible to automatically configure and build a variety of
tools with one command.  To build all of the tools contained herein,
run the ``configure'' script here, e.g.:

	./configure 
	make

To install them (by default in /usr/local/bin, /usr/local/lib, etc),
then do:
	make install

(If the configure script can't determine your type of computer, give it
the name as an argument, for instance ``./configure sun4''.  You can
use the script ``config.sub'' to test whether a name is recognized; if
it is, config.sub translates it to a triplet specifying CPU, vendor,
and OS.)

If you have more than one compiler on your system, it is often best to
explicitly set CC in the environment before running configure, and to
also set CC when running make.  For example (assuming sh/bash/ksh):

	CC=gcc ./configure
	make

A similar example using csh:

	setenv CC gcc
	./configure
	make

Much of the code and documentation enclosed is copyright by
the Free Software Foundation, Inc.  See the file COPYING or
COPYING.LIB in the various directories, for a description of the
GNU General Public License terms under which you can copy the files.

REPORTING BUGS: Again, see gdb/README, binutils/README, etc., for info
on where and how to report problems.
Description
Unofficial mirror of sourceware binutils-gdb repository. Updated daily.
Readme 944 MiB
Languages
C 50.4%
Makefile 22.7%
Assembly 13.2%
C++ 5.9%
Roff 1.5%
Other 5.7%