From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29746 invoked by alias); 6 Feb 2003 19:31:51 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 29738 invoked from network); 6 Feb 2003 19:31:50 -0000 Received: from unknown (HELO smtp013.mail.yahoo.com) (216.136.173.57) by 172.16.49.205 with SMTP; 6 Feb 2003 19:31:50 -0000 Received: from du-041-0136.access.clara.net (HELO albert) (RaoulGough@217.158.117.136 with login) by smtp.mail.vip.sc5.yahoo.com with SMTP; 6 Feb 2003 19:31:48 -0000 Message-ID: <001501c2ce16$8557a070$0100a8c0@albert> From: "Raoul Gough" To: Cc: "Christopher Faylor" References: <20030111172431.GA5683@redhat.com> <20030129152104.GD9107@redhat.com> Subject: Re: [RFC]: win32-nat.c better handling of DLL relocation Date: Thu, 06 Feb 2003 19:31:00 -0000 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_000E_01C2CE16.30628300" X-Priority: 3 X-MSMail-Priority: Normal X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-SW-Source: 2003-02/txt/msg00221.txt.bz2 This is a multi-part message in MIME format. ------=_NextPart_000_000E_01C2CE16.30628300 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-length: 415 "Christopher Faylor" wrote in message news:20030129152104.GD9107@redhat.com... [snip] > Any word on the assignment front? I've just received word that my assignment forms have been accepted at the FSF. I've attached an up-to-date diff for win32-nat.c (against CVS version 1.69) to this message, and will probably also re-post my extensions to coffread.c, etc., to the list. Regards, Raoul Gough. ------=_NextPart_000_000E_01C2CE16.30628300 Content-Type: text/plain; name="win32-nat.diff.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="win32-nat.diff.txt" Content-length: 4528 Index: win32-nat.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/win32-nat.c,v retrieving revision 1.69 diff -c -p -r1.69 win32-nat.c *** win32-nat.c 30 Jan 2003 01:39:52 -0000 1.69 --- win32-nat.c 5 Feb 2003 22:17:55 -0000 *************** child_clear_solibs (void) *** 749,760 **** solib_end =3D &solib_start; max_dll_name_len =3D sizeof ("DLL Name") - 1; } =20=20 /* Add DLL symbol information. */ static struct objfile * solib_symbols_add (char *name, int from_tty, CORE_ADDR load_addr) { ! struct section_addr_info section_addrs; =20=20 /* The symbols in a dll are offset by 0x1000, which is the the offset from 0 of the first byte in an image - because --- 749,815 ---- solib_end =3D &solib_start; max_dll_name_len =3D sizeof ("DLL Name") - 1; } + =0C + /* Get the loaded address of all sections, given that .text was loaded + at text_load. Assumes that all sections are subject to the same + relocation offset. Returns NULL if problems occur or if the + sections were not relocated. */ =20=20 + static struct section_addr_info * + get_relocated_section_addrs (bfd *abfd, CORE_ADDR text_load) + { + struct section_addr_info *result =3D NULL; + int section_count =3D bfd_count_sections (abfd); + asection *text_section =3D bfd_get_section_by_name (abfd, ".text"); + CORE_ADDR text_vma; +=20 + if (!text_section) + { + /* Couldn't get the .text section. Weird. */ + } +=20 + else if (text_load =3D=3D (text_vma =3D bfd_get_section_vma (abfd, text= _section))) + { + /* DLL wasn't relocated. */ + } +=20 + else + { + /* Figure out all sections' loaded addresses. The offset here is + such that taking a bfd_get_section_vma() result and adding + offset will give the real load address of the section. */ +=20 + CORE_ADDR offset =3D text_load - text_vma; +=20 + struct section_table *table_start =3D NULL; + struct section_table *table_end =3D NULL; + struct section_table *iter =3D NULL; +=20 + build_section_table (abfd, &table_start, &table_end); +=20 + for (iter =3D table_start; iter < table_end; ++iter) + { + /* Relocated addresses. */ + iter->addr +=3D offset; + iter->endaddr +=3D offset; + } +=20 + result =3D build_section_addr_info_from_section_table (table_start, + table_end); +=20 + xfree (table_start); + } +=20 + return result; + } + =0C /* Add DLL symbol information. */ static struct objfile * solib_symbols_add (char *name, int from_tty, CORE_ADDR load_addr) { ! struct section_addr_info *section_addrs_ptr =3D NULL; ! static struct objfile *result =3D NULL; ! bfd *abfd =3D NULL; =20=20 /* The symbols in a dll are offset by 0x1000, which is the the offset from 0 of the first byte in an image - because *************** solib_symbols_add (char *name, int from_ *** 763,772 **** if (!name || !name[0]) return NULL; =20=20 ! memset (§ion_addrs, 0, sizeof (section_addrs)); ! section_addrs.other[0].name =3D ".text"; ! section_addrs.other[0].addr =3D load_addr; ! return safe_symbol_file_add (name, from_tty, §ion_addrs, 0, OBJF_SH= ARED); } =20=20 /* Load DLL symbol info. */ --- 818,863 ---- if (!name || !name[0]) return NULL; =20=20 ! abfd =3D bfd_openr (name, "pei-i386"); !=20 ! if (!abfd) ! { ! /* pei failed - try pe */ ! abfd =3D bfd_openr (name, "pe-i386"); ! } !=20 ! if (abfd) ! { ! if (bfd_check_format (abfd, bfd_object)) ! { ! section_addrs_ptr =3D get_relocated_section_addrs (abfd, load_addr); ! } !=20 ! bfd_close (abfd); ! } !=20 ! if (section_addrs_ptr) ! { ! result =3D safe_symbol_file_add (name, from_tty, section_addrs_ptr, ! 0, OBJF_SHARED); !=20 ! free_section_addr_info (section_addrs_ptr); ! } !=20 ! else ! { ! /* Fallback on handling just the .text section. */ ! struct section_addr_info section_addrs; !=20 ! memset (§ion_addrs, 0, sizeof (section_addrs)); ! section_addrs.other[0].name =3D ".text"; ! section_addrs.other[0].addr =3D load_addr; !=20 ! result =3D safe_symbol_file_add (name, from_tty, §ion_addrs, ! 0, OBJF_SHARED); ! } !=20 ! return result; } =20=20 /* Load DLL symbol info. */ ------=_NextPart_000_000E_01C2CE16.30628300-- __________________________________________________ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com