🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #6285

bfd assertion fail elf32-i386.c:624

#6285
From: Luke Kendall
Date: Mon, 08 Jan 1996 00:00
185 lines
5547 bytes
I believe this is a bug in gcc under Linux.  Anyone know whether it's
known or not?

System:
    Linux genius 1.2.13 #12 Sun Jan 7 08:22:37 EST 1996 i486
libc:
    libc.so.5 => /lib/libc.so.5.0.9
gcc:
    Reading specs from /usr/lib/gcc-lib/i486-linuxelf/2.6.3/specs
    gcc version 2.6.3

BTW, it used to compile under pre-ELF gcc.  It's a very old program.

DESCRIPTION
-----------
    Assertion failure in gcc for simple program.

    $ cc -Wall cpiosplit.c
    bfd assertion fail elf32-i386.c:624

    (I've since realised that the code should be using lstat() instead
     of stat(), but I don't believe that's relevant.)

    See `Note 1', below, for some more details.
    See `Note 2' for the source code (about 120 lines) to cpiosplit.c.


Note 1
------
Looking inside /system_cd/devel/binutils-2.5.2l.17/bfd/elf32-i386.c.gz
I see:

  /* Make sure we know what is going on here.  */
  BFD_ASSERT (dynobj != NULL
              && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)
                  || ((h->elf_link_hash_flags
                       & ELF_LINK_HASH_DEF_DYNAMIC) != 0
                      && (h->elf_link_hash_flags
                          & ELF_LINK_HASH_REF_REGULAR) != 0
                      && (h->elf_link_hash_flags
                          & ELF_LINK_HASH_DEF_REGULAR) == 0
                      && (elf_elfheader (h->root.u.def.section->owner)->e_type
                          == ET_DYN)
                      && (h->root.type == bfd_link_hash_defined
                          || h->root.type == bfd_link_hash_defweak)
                      && (bfd_get_flavour (h->root.u.def.section->owner)
                          == bfd_target_elf_flavour)
                      && h->root.u.def.section->output_section == NULL)));

which I must confess, doesn't mean a whole lot to me.  I think this is in
the code generation phase, however, or even the linking stage.

Note 2
------
Source code for cpiosplit.c:

/*
 * Read filenames from standard input and split them into sub lists
 * so that a cpio -c of each sub list will be less than the number of
 * bytes specified by a list of sizes.
 *
 * The lists are placed in files starting with the lists-basename argument
 * with '.00', '.01', '.02' ... appended to them.
 *
 * The sizes are given by the remaining arguments.  They are used cyclically.
 *
 * Author: Tim Long
 */
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>

#define	CPIO_HDRZ	80

char	*myname;
char	*basename;
long	*sizes;
int	nsizes;
int	this_size;
int	this_list;
long	bytes_so_far;

void
usage(void)
{
    fprintf(stderr, "usage: %s lists-basename media-size...\n", myname);
}

int
main(int argc, char **argv)
{
    register int	i;
    char		*ptr;
    char		fname[1024];
    char		list_name[512];
    register FILE	*list_stream;

    myname = argv[0];

    if (argc < 3)
	usage();
    basename = argv[1];
    nsizes = argc - 2;
    if ((sizes = (long *)malloc(nsizes * sizeof sizes[0])) == NULL)
    {
	fprintf(stderr, "%s: Ran out of memory.\n", myname);
	exit(1);
    }
    for (i = 2; i < argc; i++)
    {
	sizes[i - 2] = strtol(argv[i], &ptr, 0);
	if (*ptr != '\0')
	    usage();
    }

    sprintf(list_name, "%s.%02d", basename, this_list);
    if ((list_stream = fopen(list_name, "w")) == NULL)
    {
	fprintf(stderr, "%s: Could not create %s.\n", myname, list_name);
	exit(1);
    }
    bytes_so_far = CPIO_HDRZ;

    while (gets(fname) != NULL)
    {
	struct stat	statb;
	long		fsize;
	long		cost;

	if (stat(fname, &statb) != 0)
	{
	    fprintf
	    (
		stderr, "%s: Warning; could not stat %s.  Elided from list.\n",
		myname, fname
	    );
	    continue;
	}
	if ((statb.st_mode & S_IFMT) == S_IFREG)
	    fsize = statb.st_size;
	else
	    fsize = 0;
	cost = fsize + strlen(fname) + 1 + CPIO_HDRZ;
	if (bytes_so_far + cost >= sizes[this_size])
	{
/*
fprintf(stderr, "bytes_so_far = %ld, cost = %ld, sizes[%d] = %ld\n",
bytes_so_far, cost, this_size, sizes[this_size]);
*/
	    fclose(list_stream);
	    this_list++;
	    if (++this_size >= nsizes)
		this_size = 0;
	    sprintf(list_name, "%s.%02d", basename, this_list);
	    if ((list_stream = fopen(list_name, "w")) == NULL)
	    {
		fprintf
		(
		    stderr, "%s: Could not create %s.\n", myname, list_name
		);
		exit(1);
	    }
	    bytes_so_far = CPIO_HDRZ;
	}
	fprintf(list_stream, "%s\n", fname);
	bytes_so_far += cost;
	if (bytes_so_far > sizes[this_size])
	{
	    fprintf
	    (
		stderr,
		"%s: Warning; %s has only one file but is still too big.\n",
		myname, list_name
	    );
	}
    }
    fclose(list_stream);
    return 0;
}
-- 
Luke Kendall, Senior Software Engineer.      | Net:   luke@research.canon.com.au
Canon Information Systems Research Australia | Phone: +61 2 805 2982
P.O. Box 313 North Ryde, NSW, Australia 2113 | Fax:   +61 2 805 2929
Technical Details
Message-ID: <DKuMI9.M09@research.canon.oz.au>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 113d02,6f6a63462e5378d9,start
X-Google-Attributes: gid113d02,public
From: luke@research.CAnon.oz.AU (Luke Kendall)
Subject: bfd assertion fail elf32-i386.c:624
Date: 1996/01/08
Message-ID: <DKuMI9.M09@research.canon.oz.au>
X-Deja-AN: 134453572
distribution: gnu
sender: daemon@cis.ohio-state.edu
summary: Simple program gets assertion failure
organization: Canon Information Systems Research Australia
keywords: gcc, linux, bug, elf
newsgroups: gnu.gcc.bug