From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7059 invoked by alias); 28 May 2003 15:04:44 -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 6968 invoked from network); 28 May 2003 15:04:43 -0000 Received: from unknown (HELO smtp018.mail.yahoo.com) (216.136.174.115) by sources.redhat.com with SMTP; 28 May 2003 15:04:43 -0000 Received: from adsl-solo-229-248.claranet.co.uk (HELO albert) (RaoulGough@217.158.229.248 with login) by smtp.mail.vip.sc5.yahoo.com with SMTP; 28 May 2003 15:04:40 -0000 Message-ID: <002301c3252a$9690ec00$0200a8c0@albert> From: "Raoul Gough" To: "Elena Zannoni" Cc: References: <16012.44364.781796.157557@localhost.redhat.com><018401c318a5$099c3b10$0200a8c0@albert> <16078.19295.731449.579816@localhost.redhat.com> Subject: Re: RFC: coffread.c relocation fixes Date: Wed, 28 May 2003 15:04:00 -0000 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0020_01C32532.E67ADCF0" X-Priority: 3 X-MSMail-Priority: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-SW-Source: 2003-05/txt/msg00503.txt.bz2 This is a multi-part message in MIME format. ------=_NextPart_000_0020_01C32532.E67ADCF0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-length: 1578 "Elena Zannoni" wrote in message news:16078.19295.731449.579816@localhost.redhat.com... > Raoul Gough writes: [snip] > > I've added the script as a note to PR 1132 in GNATS (see > > http://sources.redhat.com/ml/gdb-prs/2003-q2/msg00129.html). > > > > I don't have much comments on the test (except that the convention is > to use '-' instead of '_' in file names, and that you need to update > the gdb/config/djgpp/fnchange.lst file). I wonder if instead of 'while 1' > you could use exp_continue. MichaelC? Oh, DOS 8.3 filenames - I see... probably best to rename the files everywhere - otherwise the shared-reloc.exp script would have to be aware of the renaming issue on DJGPP (since it invokes the compiler on the long-named .c files). I've attached the new versions to this post. BTW, I think Andrew Cagney is sorting out CVS access for me, so I may be able to add the test to CVS myself, if that's appropriate. I wonder if this test works on DJGPP? Regarding the "while 1" issue - my TCL/expect skills are so minimal, I couldn't think of a better way of doing the loop - an improvement would be good, as long as it doesn't involve me learning any more TCL :-) > > I've attached an updated diff to this posting with a fix for the typo > > that Elena identified. Any advice on getting these patches checked in > > and the PR closed? I can't do it myself, since I don't have any write > > access. > > > > I can commit it for you. Thanks for this - the latest CVS version now passes the shared object relocation tests. Regards, Raoul Gough. ------=_NextPart_000_0020_01C32532.E67ADCF0 Content-Type: text/plain; name="shreloc.c" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="shreloc.c" Content-length: 344 #if defined(_WIN32) || defined(__CYGWIN__) # define ATTRIBUTES __attribute((__dllimport__)) #else # define ATTRIBUTES #endif extern ATTRIBUTES void fn_1 (int); extern ATTRIBUTES void fn_2 (int); extern ATTRIBUTES int extern_var_1; extern ATTRIBUTES int extern_var_2; int main () { fn_1 (extern_var_1); fn_2 (extern_var_2); return 0; } ------=_NextPart_000_0020_01C32532.E67ADCF0 Content-Type: text/plain; name="shreloc2.c" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="shreloc2.c" Content-length: 223 #if defined(_WIN32) || defined(__CYGWIN__) # define ATTRIBUTES __attribute((__dllexport__)) #else # define ATTRIBUTES #endif static int static_var_2; ATTRIBUTES void fn_2 (int unused) { } ATTRIBUTES int extern_var_2 = 0; ------=_NextPart_000_0020_01C32532.E67ADCF0 Content-Type: text/plain; name="shreloc1.c" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="shreloc1.c" Content-length: 223 #if defined(_WIN32) || defined(__CYGWIN__) # define ATTRIBUTES __attribute((__dllexport__)) #else # define ATTRIBUTES #endif static int static_var_1; ATTRIBUTES void fn_1 (int unused) { } ATTRIBUTES int extern_var_1 = 0; ------=_NextPart_000_0020_01C32532.E67ADCF0 Content-Type: application/octet-stream; name="shreloc.exp" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="shreloc.exp" Content-length: 7998 # Copyright (C) 2003 Free Software Foundation, Inc.=0A= #=0A= # This program is free software; you can redistribute it and/or modify=0A= # it under the terms of the GNU General Public License as published by=0A= # the Free Software Foundation; either version 2 of the License, or=0A= # (at your option) any later version.=0A= #=0A= # This program is distributed in the hope that it will be useful,=0A= # but WITHOUT ANY WARRANTY; without even the implied warranty of=0A= # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the=0A= # GNU General Public License for more details.=0A= #=0A= # You should have received a copy of the GNU General Public License=0A= # along with this program; if not, write to the Free Software=0A= # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA= .=0A= #=0A= =0A= # Please email any bugs, comments, and/or additions to this file to:=0A= # bug-gdb@prep.ai.mit.edu=0A= =0A= # Tests for shared object file relocation. If two shared objects have=0A= # the same load address (actually, overlapping load spaces), one of=0A= # them gets relocated at load-time. Check that gdb gets the right=0A= # values for the debugging and minimal symbols.=0A= =0A= if $tracelevel then {=0A= strace $tracelevel=0A= }=0A= =0A= #=0A= # This file uses shreloc.c, shreloc1.c and shreloc2.c=0A= #=0A= =0A= set prms_id 0=0A= set bug_id 0=0A= =0A= set workdir ${objdir}/${subdir}=0A= =0A= foreach module [list "shreloc" "shreloc1" "shreloc2"] {=0A= if {[gdb_compile "${srcdir}/${subdir}/${module}.c" "${workdir}/${module= }.o" object {debug}] !=3D ""} {=0A= gdb_suppress_entire_file "${module}.c compile failed, so all tests in this= file will automatically fail."=0A= return -1=0A= }=0A= }=0A= =0A= set additional_flags "additional_flags=3D-shared"=0A= =0A= if {([istarget "*pc-cygwin"] || [istarget "*pc-mingw32"]) } {=0A= set additional_flags "${additional_flags} -Wl,--image-base,0x04000000"= =0A= }=0A= =0A= foreach module [list "shreloc1" "shreloc2"] {=0A= if {[gdb_compile "${workdir}/${module}.o" "${workdir}/${module}.dll" ex= ecutable [list debug $additional_flags]] !=3D ""} {=0A= gdb_suppress_entire_file "${module}.dll link failed, so all tests in this = file will automatically fail."=0A= return -1=0A= }=0A= }=0A= =0A= if {[gdb_compile [list "${workdir}/shreloc.o" "${workdir}/shreloc1.dll" "${= workdir}/shreloc2.dll"] "${workdir}/shreloc" executable debug] !=3D ""} {= =0A= gdb_suppress_entire_file "shreloc link failed, so all tests in this fil= e will automatically fail."=0A= return -1=0A= }=0A= =0A= gdb_exit=0A= gdb_start=0A= gdb_reinitialize_dir $srcdir/$subdir=0A= gdb_load ${workdir}/shreloc=0A= =0A= # Load up the shared objects=0A= if ![runto_main] then {=0A= fail "Can't run to main"=0A= return 0=0A= }=0A= =0A= proc get_var_address { var } {=0A= global gdb_prompt hex=0A= =0A= send_gdb "print &${var}\n"=0A= # Match output like:=0A= # $1 =3D (int *) 0x0=0A= # $5 =3D (int (*)()) 0=0A= # $6 =3D (int (*)()) 0x24 =0A= gdb_expect {=0A= -re "\\\$\[0-9\]+ =3D \\(.*\\) (0|$hex)( <${var}>)?\[\r\n\]+${gdb_promp= t} $"=0A= {=0A= pass "get address of ${var}"=0A= if { $expect_out(1,string) =3D=3D "0" } {=0A= return "0x0"=0A= } else {=0A= return $expect_out(1,string)=0A= }=0A= }=0A= -re "${gdb_prompt} $"=0A= { fail "get address of ${var} (unknown output)" }=0A= timeout=0A= { fail "get address of ${var} (timeout)" }=0A= }=0A= return ""=0A= }=0A= =0A= #=0A= # Check debugging symbol relocations=0A= #=0A= =0A= # Check extern function for relocation=0A= set fn_1_addr [get_var_address fn_1]=0A= set fn_2_addr [get_var_address fn_2]=0A= =0A= if { "${fn_1_addr}" =3D=3D "${fn_2_addr}" } {=0A= fail "relocated extern functions have different addresses"=0A= } else {=0A= pass "relocated extern functions have different addresses"=0A= }=0A= =0A= # Check extern var for relocation=0A= set extern_var_1_addr [get_var_address extern_var_1]=0A= set extern_var_2_addr [get_var_address extern_var_2]=0A= =0A= if { "${extern_var_1_addr}" =3D=3D "${extern_var_2_addr}" } {=0A= fail "relocated extern variables have different addresses"=0A= } else {=0A= pass "relocated extern variables have different addresses"=0A= }=0A= =0A= # Check static var for relocation=0A= set static_var_1_addr [get_var_address static_var_1]=0A= set static_var_2_addr [get_var_address static_var_2]=0A= =0A= if { "${static_var_1_addr}" =3D=3D "${static_var_2_addr}" } {=0A= fail "relocated static variables have different addresses"=0A= } else {=0A= pass "relocated static variables have different addresses"=0A= }=0A= =0A= #=0A= # Check minimal symbol relocations=0A= #=0A= =0A= proc send_gdb_discard { command } {=0A= # Send a command to gdb and discard output up to the next prompt=0A= =0A= global gdb_prompt=0A= =0A= send_gdb "${command}\n"=0A= =0A= # Discard output=0A= gdb_expect {=0A= -re ".*\[\r\n]+${gdb_prompt} $" {=0A= return 1=0A= }=0A= timeout {=0A= fail "{$command} (timeout)"=0A= return 0=0A= }=0A= }=0A= }=0A= =0A= proc get_msym_addrs { var msymfile } {=0A= # Extract the list of values for symbols matching var in the=0A= # minimal symbol output file=0A= =0A= global gdb_prompt hex=0A= set result ""=0A= =0A= send_gdb "shell grep -E \" ${var}(\[ \t\]+.*)?\$\" ${msymfile}\n"=0A= =0A= while 1 {=0A= gdb_expect {=0A= -re "\[\[\]\[ 0-9\]+\] . (${hex}) ${var}(\[ \t\]+\[^\r\n\]*)?\[\r\n\]+= " {=0A= set result [concat $result $expect_out(1,string)]=0A= }=0A= =0A= -re "$gdb_prompt $" {=0A= pass "get_msym_addrs ${var} (${result})"=0A= return "${result}"=0A= }=0A= =0A= -re "\[^\r\n\]*\[\r\n\]+" {=0A= # Skip=0A= }=0A= =0A= timeout {=0A= fail "get_msym_addrs ${var} (timeout)"=0A= return -1=0A= }=0A= }=0A= }=0A= }=0A= =0A= proc check_same {var msymfile} {=0A= # Check that the minimal symbol values matching var are the same=0A= =0A= set len [llength [lsort -unique [get_msym_addrs "${var}" "${msymfile}"]= ]]=0A= =0A= if { $len =3D=3D 1 } {=0A= return 1=0A= } else {=0A= return 0=0A= }=0A= }=0A= =0A= proc check_different {var msymfile} {=0A= # Check that the minimal symbol values matching var are different=0A= =0A= set addr_list [lsort [get_msym_addrs "${var}" "${msymfile}"]]=0A= set prev ""=0A= =0A= if { [llength ${addr_list}] < 2 } {=0A= return 0=0A= }=0A= =0A= foreach addr ${addr_list} {=0A= if { ${prev} =3D=3D ${addr} } {=0A= return 0=0A= }=0A= set prev ${addr}=0A= }=0A= =0A= return 1=0A= }=0A= =0A= set msymfile "${workdir}/shreloc.txt"=0A= =0A= if [send_gdb_discard "maint print msymbols ${msymfile}"] {=0A= if {[check_different "static_var_\[12\]" "${msymfile}"]} {=0A= pass "(msymbol) relocated static vars have different addresses"=0A= } else {=0A= fail "(msymbol) relocated static vars have different addresses"=0A= }=0A= =0A= if {[check_different "extern_var_\[12\]" "${msymfile}"]} {=0A= pass "(msymbol) relocated extern vars have different addresses"=0A= } else {=0A= fail "(msymbol) relocated extern vars have different addresses"=0A= }=0A= =0A= if {[check_different "fn_\[12\]" "${msymfile}"]} {=0A= pass "(msymbol) relocated functions have different addresses"=0A= } else {=0A= fail "(msymbol) relocated functions have different addresses"=0A= }=0A= }=0A= =0A= if {([istarget "*pc-cygwin"] || [istarget "*pc-mingw32"]) } {=0A= #=0A= # We know the names of some absolute symbols included in the=0A= # portable-executable (DLL) format. Check that they didn't get=0A= # relocated.=0A= #=0A= # A better approach would be include absolute symbols via the assembler= .=0A= #=0A= if {[check_same "_minor_os_version__" "${msymfile}"]} {=0A= pass "Absolute symbols not relocated"=0A= } else {=0A= fail "Absolute symbols not relocated"=0A= }=0A= }=0A= ------=_NextPart_000_0020_01C32532.E67ADCF0--