From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15937 invoked by alias); 1 Feb 2005 22:46:04 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 15240 invoked from network); 1 Feb 2005 22:45:51 -0000 Received: from unknown (HELO rwcrmhc13.comcast.net) (204.127.198.39) by sourceware.org with SMTP; 1 Feb 2005 22:45:51 -0000 Received: from lucon.org ([24.6.212.230]) by comcast.net (rwcrmhc13) with ESMTP id <20050201224551015009t68je>; Tue, 1 Feb 2005 22:45:51 +0000 Received: by lucon.org (Postfix, from userid 1000) id E44EE63FD1; Tue, 1 Feb 2005 14:45:50 -0800 (PST) Date: Tue, 01 Feb 2005 22:46:00 -0000 From: "H. J. Lu" To: binutils@sources.redhat.com Subject: Re: IA64 linker is totally broken (Re: PATCH: ELF linker is broken) Message-ID: <20050201224550.GA19843@lucon.org> References: <20050130192249.GA21997@lucon.org> <20050131000227.GF11595@bubble.modra.org> <20050131071308.GH11595@bubble.modra.org> <20050131212203.GA27701@lucon.org> <20050131220214.GA28324@lucon.org> <20050201000825.GK11595@bubble.modra.org> <20050201055618.GA5203@lucon.org> <20050201061826.GA5603@lucon.org> <20050201071606.GQ11595@bubble.modra.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050201071606.GQ11595@bubble.modra.org> User-Agent: Mutt/1.4.1i X-SW-Source: 2005-02/txt/msg00038.txt.bz2 On Tue, Feb 01, 2005 at 05:46:06PM +1030, Alan Modra wrote: > On Mon, Jan 31, 2005 at 10:18:26PM -0800, H. J. Lu wrote: > > ./ld: BFD 2.15.94.0.3 20050201 assertion fail > > /net/gnu/export/linux/src/binutils/binutils/bfd/elf-strtab.c:241 > > ./ld: BFD 2.15.94.0.3 20050201 assertion fail > > /net/gnu/export/linux/src/binutils/binutils/bfd/elf-strtab.c:241 > > Can you tell me what is in table[i]->root.string, so I have a clue > what's going wrong? Or better, send me a set of ia64 object files > and libs that exhibit the problem. There are quite a few failures on ia64. I am not sure if they can be fixed by a single change. I am enclosing the cause of all the problems I have seen so far on ia64. IA64 linker has a relaxation pass, which seems to be the problem. Dos it ring a bell to you? If not, I will send you a bunch of ia64 binaries as a testcase. H.J. --- Index: bfd/elflink.c =================================================================== RCS file: /cvs/src/src/bfd/elflink.c,v retrieving revision 1.125 diff -u -p -r1.125 elflink.c --- bfd/elflink.c 31 Jan 2005 23:13:26 -0000 1.125 +++ bfd/elflink.c 1 Feb 2005 00:41:30 -0000 @@ -2813,6 +2813,69 @@ elf_add_dt_needed_tag (bfd *abfd, return 0; } +/* Called via elf_link_hash_traverse, elf_smash_syms sets all symbols + belonging to NOT_NEEDED to bfd_link_hash_new. We know there are no + references to these symbols. */ + +struct elf_smash_syms_data +{ + bfd *not_needed; + struct elf_link_hash_table *htab; + bfd_boolean twiddled; +}; + +static bfd_boolean +elf_smash_syms (struct elf_link_hash_entry *h, void *data) +{ + struct elf_smash_syms_data *inf = (struct elf_smash_syms_data *) data; + struct bfd_link_hash_entry *bh; + + switch (h->root.type) + { + default: + case bfd_link_hash_new: + return TRUE; + + case bfd_link_hash_undefined: + case bfd_link_hash_undefweak: + if (h->root.u.undef.abfd != inf->not_needed) + return TRUE; + break; + + case bfd_link_hash_defined: + case bfd_link_hash_defweak: + if (h->root.u.def.section->owner != inf->not_needed) + return TRUE; + break; + + case bfd_link_hash_common: + if (h->root.u.c.p->section->owner != inf->not_needed) + return TRUE; + break; + + case bfd_link_hash_warning: + case bfd_link_hash_indirect: + elf_smash_syms ((struct elf_link_hash_entry *) h->root.u.i.link, data); + if (h->root.u.i.link->type != bfd_link_hash_new) + return TRUE; + if (h->root.u.i.link->u.undef.abfd != inf->not_needed) + return TRUE; + break; + } + + /* Set sym back to newly created state, but keep undefs list pointer. */ + bh = h->root.u.undef.next; + if (bh != NULL || inf->htab->root.undefs_tail == &h->root) + inf->twiddled = TRUE; + (*inf->htab->root.table.newfunc) (&h->root.root, + &inf->htab->root.table, + h->root.root.string); + h->root.u.undef.next = bh; + h->root.u.undef.abfd = inf->not_needed; + h->non_elf = 0; + return TRUE; +} + /* Sort symbol by value and section. */ static int elf_sort_symbol (const void *arg1, const void *arg2) @@ -4031,6 +4094,18 @@ elf_link_add_object_symbols (bfd *abfd, free (isymbuf); isymbuf = NULL; + if (!add_needed) + { + struct elf_smash_syms_data inf; + inf.not_needed = abfd; + inf.htab = hash_table; + inf.twiddled = FALSE; + elf_link_hash_traverse (hash_table, elf_smash_syms, &inf); + if (inf.twiddled) + bfd_link_repair_undef_list (&hash_table->root); + weaks = NULL; + } + /* Now set the weakdefs field correctly for all the weak defined symbols we found. The only way to do this is to search all the symbols. Since we only need the information for non functions in