From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9888 invoked by alias); 4 Jul 2002 05:24:21 -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 9880 invoked from network); 4 Jul 2002 05:24:20 -0000 Received: from unknown (HELO mta05bw.bigpond.com) (139.134.6.95) by sources.redhat.com with SMTP; 4 Jul 2002 05:24:20 -0000 Received: from bubble.local ([144.135.24.81]) by mta05bw.bigpond.com (Netscape Messaging Server 4.15 mta05bw Apr 29 2002 13:22:02) with SMTP id GYPLOI00.7Y0 for ; Thu, 4 Jul 2002 15:24:18 +1000 Received: from CPE-144-136-176-14.sa.bigpond.net.au ([144.136.176.14]) by bwmam05.mailsvc.email.bigpond.com(MailRouter V3.0n 44/1678739); 04 Jul 2002 15:24:18 Received: (qmail 15495 invoked by uid 179); 4 Jul 2002 05:24:18 -0000 Date: Thu, 04 Jul 2002 00:19:00 -0000 From: Alan Modra To: ross.alexander@uk.neceur.com Cc: law@redhat.com, binutils@sources.redhat.com Subject: Re: hppa64-hp-hpux11.00: HP ELF64 brokeness (incorrect .dynamic section) Message-ID: <20020704052418.GN22093@bubble.sa.bigpond.net.au> Mail-Followup-To: ross.alexander@uk.neceur.com, law@redhat.com, binutils@sources.redhat.com References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.25i X-SW-Source: 2002-07/txt/msg00087.txt.bz2 On Wed, Jul 03, 2002 at 12:35:04PM +0100, ross.alexander@uk.neceur.com wrote: > > HP have sent me a copy of ld64 with the bug fixed but here is the patch > anyway. > > bfd/Changelog > * elf.c (bfd_elf_get_bfd_needed_list): Current HP ld64 and existing > shared Thanks. I'm going to propose a different patch though, because I noticed that we already do hpux fudges for this problem in elflink.h:elf_link_add_object_symbols, and we also need to fix elf.c:_bfd_elf_print_private_bfd_data. Would you mind checking that the following does indeed cure the hpux shared lib problem? * elflink.h (elf_link_add_object_symbols): Revert 1999-09-02 hpux fudge. * elf.c (bfd_section_from_shdr): Work around broken hpux shared libs here instead. -- Alan Modra IBM OzLabs - Linux Technology Centre Index: bfd/elf.c =================================================================== RCS file: /cvs/src/src/bfd/elf.c,v retrieving revision 1.151 diff -u -p -r1.151 elf.c --- bfd/elf.c 2 Jul 2002 04:31:22 -0000 1.151 +++ bfd/elf.c 4 Jul 2002 04:49:34 -0000 @@ -1661,7 +1661,6 @@ bfd_section_from_shdr (abfd, shindex) return true; case SHT_PROGBITS: /* Normal section with contents. */ - case SHT_DYNAMIC: /* Dynamic linking information. */ case SHT_NOBITS: /* .bss section. */ case SHT_HASH: /* .hash section. */ case SHT_NOTE: /* .note section. */ @@ -1669,6 +1668,39 @@ bfd_section_from_shdr (abfd, shindex) case SHT_FINI_ARRAY: /* .fini_array section. */ case SHT_PREINIT_ARRAY: /* .preinit_array section. */ return _bfd_elf_make_section_from_shdr (abfd, hdr, name); + + case SHT_DYNAMIC: /* Dynamic linking information. */ + if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name)) + return false; + if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_STRTAB) + { + Elf_Internal_Shdr *dynsymhdr; + + /* The shared libraries distributed with hpux11 have a bogus + sh_link field for the ".dynamic" section. Find the + string table for the ".dynsym" section instead. */ + if (elf_dynsymtab (abfd) != 0) + { + dynsymhdr = elf_elfsections (abfd)[elf_dynsymtab (abfd)]; + hdr->sh_link = dynsymhdr->sh_link; + } + else + { + unsigned int i, num_sec; + + num_sec = elf_numsections (abfd); + for (i = 1; i < num_sec; i++) + { + dynsymhdr = elf_elfsections (abfd)[i]; + if (dynsymhdr->sh_type == SHT_DYNSYM) + { + hdr->sh_link = dynsymhdr->sh_link; + break; + } + } + } + } + break; case SHT_SYMTAB: /* A symbol table */ if (elf_onesymtab (abfd) == shindex) Index: bfd/elflink.h =================================================================== RCS file: /cvs/src/src/bfd/elflink.h,v retrieving revision 1.172 diff -u -p -r1.172 elflink.h --- bfd/elflink.h 1 Jul 2002 08:06:46 -0000 1.172 +++ bfd/elflink.h 4 Jul 2002 04:49:40 -0000 @@ -1451,23 +1451,6 @@ elf_link_add_object_symbols (abfd, info) goto error_return; shlink = elf_elfsections (abfd)[elfsec]->sh_link; - { - /* The shared libraries distributed with hpux11 have a bogus - sh_link field for the ".dynamic" section. This code detects - when SHLINK refers to a section that is not a string table - and tries to find the string table for the ".dynsym" section - instead. */ - Elf_Internal_Shdr *shdr = elf_elfsections (abfd)[shlink]; - if (shdr->sh_type != SHT_STRTAB) - { - asection *ds = bfd_get_section_by_name (abfd, ".dynsym"); - int elfdsec = _bfd_elf_section_from_bfd_section (abfd, ds); - if (elfdsec == -1) - goto error_return; - shlink = elf_elfsections (abfd)[elfdsec]->sh_link; - } - } - extdyn = dynbuf; extdynend = extdyn + s->_raw_size / sizeof (Elf_External_Dyn); rpath = 0;