Go to file
Simon Marchi 59f837cb11 gdb: initialize ctf_context::builder in create_partial_symtab
I built a random project with -gctf, in order to test the CTF support in
GDB.  With my ASan/UBSan/etc-enabled build of GDB, I get:

    $ ./gdb --data-directory=data-directory /tmp/babeltrace-ctf/src/lib/.libs/libbabeltrace2.so.0.0.0
    ...
    Reading symbols from /tmp/babeltrace-ctf/src/lib/.libs/libbabeltrace2.so.0.0.0...
    /home/simark/src/binutils-gdb/gdb/ctfread.c:1545:31: runtime error: member call on misaligned address 0xbebebebebebebebe for type 'struct buildsym_compunit', which requires 8 byte alignment
    0xbebebebebebebebe: note: pointer points here

The 0xbebebebebebebebe value is a sign that the ctf_context::builder
field is uninitialized.  The problem probably goes under the radar if
the field happens to be zero-initialized, because ctf_start_archive
contains this code:

  if (ccx->builder == nullptr)
    {
      ccx->builder = new buildsym_compunit (of,
		      of->original_name, nullptr, language_c, 0);

If the field was zero-initialized (by chance), this will create a new
buildsym_compunit.  But if the field was purposely filled with random
bytes by one of the sanitizers, we won't create a buildsym_compunit here
and we'll continue with ccx->builder equal to 0xbebebebebebebebe.

Fix this the easy way by initializing ccx->builder where the other
ctf_context fields are initialized (yeah, this code could be made nicer
C++, but I am going for the obvious fix here).

With this patch, this passes cleanly on my system:

  $ make check TESTS="gdb.ctf/*.exp" RUNTESTFLAGS="CC_FOR_TARGET=/opt/gcc/git/bin/gcc"
  # of expected passes            40

... where /opt/gcc/git/bin/gcc is a gcc with CTF support, given my
system gcc does not have it.

Change-Id: Idea1b0cf3e3708b72ecb16b1b60222439160f9b9
2022-03-31 16:35:56 -04:00
bfd Automatic date update in version.in 2022-03-31 00:00:06 +00:00
binutils Accept the + character as part of filenames for MRI scripts. 2022-03-31 15:43:42 +01:00
config
contrib
cpu
elfcpp
etc
gas aarch64: Relax check for RNG system registers 2022-03-31 17:51:16 +01:00
gdb gdb: initialize ctf_context::builder in create_partial_symtab 2022-03-31 16:35:56 -04:00
gdbserver gdbserver/linux: set lwp !stopped when failing to resume 2022-03-31 13:04:22 -04:00
gdbsupport Consolidate definition of current_directory 2022-03-30 09:08:48 -06:00
gnulib
gold
gprof libtool.m4: fix the NM="/nm/over/here -B/option/with/path" case 2022-03-25 12:02:35 +00:00
gprofng libtool.m4: fix the NM="/nm/over/here -B/option/with/path" case 2022-03-25 12:02:35 +00:00
include include, libctf, ld: extend variable section to contain functions too 2022-03-23 13:48:32 +00:00
intl
ld libtool.m4: fix the NM="/nm/over/here -B/option/with/path" case 2022-03-25 12:02:35 +00:00
libbacktrace libtool.m4: fix the NM="/nm/over/here -B/option/with/path" case 2022-03-25 12:02:35 +00:00
libctf libtool.m4: fix the NM="/nm/over/here -B/option/with/path" case 2022-03-25 12:02:35 +00:00
libdecnumber
libiberty
opcodes aarch64: Relax check for RNG system registers 2022-03-31 17:51:16 +01:00
readline
sim Fix for MUL instruction on the v850 2022-03-29 20:08:35 -04:00
texinfo
zlib libtool.m4: fix the NM="/nm/over/here -B/option/with/path" case 2022-03-25 12:02:35 +00:00
.cvsignore
.editorconfig
.gitattributes
.gitignore
ar-lib
ChangeLog
compile
config-ml.in
config.guess
config.rpath
config.sub
configure
configure.ac
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.LIBGLOSS
COPYING.NEWLIB
depcomp
djunpack.bat
install-sh
libtool.m4 libtool.m4: fix the NM="/nm/over/here -B/option/with/path" case 2022-03-25 12:02:35 +00:00
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS
Makefile.def
Makefile.in
Makefile.tpl
makefile.vms
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
README-maintainer-mode
setup.com
src-release.sh
symlink-tree
test-driver
ylwrap

		   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;  if with a libg++ release,
see libg++/README, etc.  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.