Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Kevin Buettner <kevinb@cygnus.com>
To: Fernando Nasser <fnasser@redhat.com>,
	Michael Elizabeth Chastain <chastain@cygnus.com>,
	ac131313@cygnus.com, keiths@cygnus.com,
	gdb-patches@sources.redhat.com
Subject: Re: [RFA] Assuming malloc exists in callfwmall.exp
Date: Thu, 15 Feb 2001 06:54:00 -0000	[thread overview]
Message-ID: <1010215145030.ZM8431@ocotillo.lan> (raw)
In-Reply-To: <3A8B9F36.B7A6DE25@redhat.com>

On Feb 15,  4:19am, Fernando Nasser wrote:

> I may have found a use for this test:
> 
> test the error message issued when no malloc() is available.
> 
> We can use Michaels code to test for malloc() and skip the tests if
> malloc() is present.
> 
> If malloc() is NOT present, then we leave (do not delete) one of the
> tests that has a string argument -- just one is enough -- and check for
> the error message that is issued.

I am in favor of this very much abbreviated test.

> Question: which target would not have malloc() available?  Some embedded
> target linked with newlib where neither the program nor any of the
> library functions it calls use malloc()?

That sounds right to me.

It *seemed* to me that it should be possible to construct an
executable which wouldn't have malloc for nearly any target.  But this
turns out to be very difficult.  My idea was to take a small program
which didn't call malloc(), nor any C library functions and statically
link it.

To that end, I played around with the following program on my Linux
box...

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

I compiled it statically, so that malloc wouldn't creep in through
the dynamic linker (ld-linux.so.2 defines a rudimentary malloc via
a weak symbol that the dynamic linker uses to load shared libraries).
But, it turns out that malloc is still linked in anyway...

(gdb) b malloc
Breakpoint 1 at 0x8048c7a: file malloc.c, line 2691.
(gdb) r
Starting program: /home/kev/ctests/empty 

Breakpoint 1, __libc_malloc (bytes=8) at malloc.c:2697
2697    malloc.c: No such file or directory.
(gdb) bt
#0  __libc_malloc (bytes=8) at malloc.c:2697
#1  0x8053824 in _dl_important_hwcaps (platform=0x0, platform_len=0, 
    sz=0x809c470, max_capstrlen=0x809c474) at dl-support.c:189
#2  0x804d856 in _dl_init_paths (llp=0x0) at dl-load.c:576
#3  0x80536d7 in non_dynamic_init () at dl-support.c:143
#4  0x8053ba0 in __libc_init (argc=1, argv=0xbffffac4, envp=0xbffffacc)
    at set-init.c:23
#5  0x8053a1b in init (argc=1, argv=0xbffffac4, envp=0xbffffacc)
    at ../sysdeps/unix/sysv/linux/init-first.c:96
#6  0x8048294 in __libc_start_main (main=0x80481dc <main>, argc=1, 
    ubp_av=0xbffffac4, init=0x80480b4 <_init>, fini=0x808c680 <_fini>, 
    rtld_fini=0, stack_end=0xbffffabc) at ../sysdeps/generic/libc-start.c:109

I suspect that most targets which use glibc will show similar results.
It would be possible to supply alternate runtime initialization code,
but I think that putting the end result in the testsuite would result
in something that is hard to maintain.

Anyway, as I mentioned earlier, I am in favor of Fernando's abbreviated
tests.

Kevin


  reply	other threads:[~2001-02-15  6:54 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-14 19:27 Michael Elizabeth Chastain
2001-02-15  1:06 ` Fernando Nasser
2001-02-15  1:22   ` Fernando Nasser
2001-02-15  6:54     ` Kevin Buettner [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-02-16  9:48 Michael Elizabeth Chastain
2001-02-16  8:55 Michael Elizabeth Chastain
2001-02-16  8:41 Michael Elizabeth Chastain
2001-02-15 19:05 Michael Elizabeth Chastain
2001-02-16  8:36 ` Jim Blandy
2001-02-15 12:58 Michael Elizabeth Chastain
2001-02-15 12:56 Michael Elizabeth Chastain
2001-02-16  8:51 ` Jim Blandy
2001-02-15 12:30 Michael Elizabeth Chastain
2001-02-15 12:48 ` Fernando Nasser
2001-02-15 12:16 Michael Elizabeth Chastain
2001-02-15 23:36 ` Eli Zaretskii
2001-02-15 12:08 Michael Elizabeth Chastain
2001-02-15 12:41 ` Fernando Nasser
2001-02-15  9:00 Michael Elizabeth Chastain
2001-02-15 11:53 ` Fernando Nasser
2001-02-15 11:56 ` Jim Blandy
2001-02-15  8:30 Michael Elizabeth Chastain
2001-02-15  8:45 ` Fernando Nasser
2001-02-15  7:54 Michael Elizabeth Chastain
2001-02-15  8:09 ` Fernando Nasser
2001-02-15  7:09 Michael Elizabeth Chastain
2001-02-15  7:06 Michael Elizabeth Chastain
2001-02-15  7:32 ` Fernando Nasser
2001-02-14 18:35 Michael Elizabeth Chastain
2001-02-14 16:29 Michael Elizabeth Chastain
2001-02-14 18:17 ` Andrew Cagney
2001-02-14 15:12 Michael Elizabeth Chastain
2001-02-14 14:17 Michael Elizabeth Chastain
2001-02-14 14:37 ` Kevin Buettner
2001-02-14 13:41 Michael Elizabeth Chastain
2001-02-14  9:06 Michael Elizabeth Chastain
2001-02-14  9:07 ` Keith Seitz
2001-02-14  9:11 ` Fernando Nasser
     [not found] <Pine.SOL.3.91.1010214082014.13194C-100000@ryobi.cygnus.com>
2001-02-14  9:02 ` Fernando Nasser
2001-02-14 12:52   ` Michael Snyder
2001-02-14 13:10     ` Kevin Buettner
2001-02-14 13:28       ` Elena Zannoni
2001-02-14 13:41         ` Kevin Buettner
2001-02-14 14:00           ` Elena Zannoni
2001-02-14 20:13           ` Andrew Cagney
2001-02-15  1:14             ` Fernando Nasser
2001-02-15 10:34               ` Andrew Cagney
2001-02-14 14:33         ` Michael Snyder
2001-02-14 14:49           ` Elena Zannoni
2001-02-14 14:34       ` Michael Snyder
2001-02-14 13:12     ` Keith Seitz
2001-02-14 13:20     ` Fernando Nasser
2001-02-14 13:37       ` Stan Shebs
2001-02-14 13:46         ` Fernando Nasser
2001-02-14 14:35         ` Michael Snyder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1010215145030.ZM8431@ocotillo.lan \
    --to=kevinb@cygnus.com \
    --cc=ac131313@cygnus.com \
    --cc=chastain@cygnus.com \
    --cc=fnasser@redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=keiths@cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox