From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by sourceware.org (Postfix) with ESMTPS id 4B7BD3858D1E for ; Sun, 25 Feb 2024 16:01:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4B7BD3858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4B7BD3858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708876864; cv=none; b=dr6Qg9MeOaH0eORCAIiV8HOLWCcrksg7gWYs11WYLlPknn7OmfJZZ+1tTiF6erFZVfFSaN6gdtdnSHDpaP7Fbz3vRtQZwPGB8r+uwis4QvnMWDUfOBQ6fkd/eW8cXz0fnlBU4/iF3jEN6fvUQkony+2A+JxTPeX9wodZShPIhQ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708876864; c=relaxed/simple; bh=VysMOpYL4hQXCyzib2rgazjms31fDcjM/weegELiqgU=; h=MIME-Version:From:Date:Message-ID:Subject:To; b=GW9lp8lS1x6cpUfkMhlE+pls9AMvtTdxRLddZTdcYMNBiA9n57ff4Dm48Y4ROhdUxf+XQcscTvExcuNu602pT3CnuSM6+yQlQdgyp9NBpJW51v8JPlc9/Q91lAM/Nr9VIX5NFp7l4QmYPxAWi8+ivsZJqH+RPlwplLt5LzhlWtM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1dc3b4b9b62so19929235ad.1 for ; Sun, 25 Feb 2024 08:01:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708876860; x=1709481660; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1I7YJGLgvcXsnLg/PGHfMrhxIee/I9ny8QnFgbSp9BE=; b=WgbPdxc+bSmcIX50QtHTxRIKw8YJO3kwom9qmpnOd1W1MEuKzIwzDp2UbAOYglgpHP /KwlrCaoTV+X6PdSX+gqykPh1U33vaRMlGFKKjBpScNAgCcDVotES/Z1LMwt21vNkko5 sWyao6wpSaMOwPrYpFRVSbprgykcD9S/RmAM4lIbyUnAUB13Kmd16VzCnua+T9LtWmaX pGVXhyrl8MR20h9+BR1xOYl6WUdo8jzHpKAhPC6diQZz/Ew68+UOLts2m4/rrKXdx60z /pLmVTcEfJy0cgyXcjR5eKwOVu+yz7FNInmHPOCWoRUBpgiP6p43H3uyRhqOLPprjf/g 6muA== X-Forwarded-Encrypted: i=1; AJvYcCWAQ+KXcxY/sjDwt8hh2CKvhkoynqsSgi/lNXx4WqlzH1t+l/cXZddF2vxdZggdPbH/eNFcJAhvMN5Nxkv6QVvDIpCRbaW4+w== X-Gm-Message-State: AOJu0YyPgfQLEoW9ob9avLD6AXKfTlwRpMWWmCmTnXFGTrAXZN9x2CtF J54ksJUcVgCTsDf+VDKW3OTGvfHDrEDfGp7yiRd1xreYUA42wkQtJ2tsdmcgfAg= X-Google-Smtp-Source: AGHT+IGwkl2Nsy9y/r1gOwtjhNKkmYLxIl7YjCLc6MCUkMyDiDYjbD/LNMjvthJ79VijWyajb0VByQ== X-Received: by 2002:a17:902:ce91:b0:1d9:4106:b8b5 with SMTP id f17-20020a170902ce9100b001d94106b8b5mr6503831plg.11.1708876859908; Sun, 25 Feb 2024 08:00:59 -0800 (PST) Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com. [209.85.214.179]) by smtp.gmail.com with ESMTPSA id l3-20020a170902e2c300b001d71729ec9csm2397021plc.188.2024.02.25.08.00.59 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 25 Feb 2024 08:00:59 -0800 (PST) Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1dc3b4b9b62so19929165ad.1 for ; Sun, 25 Feb 2024 08:00:59 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUSC7n/T3CGF5D+PsCC+ItYMjKZXG1fKzA0qwLiRlKtKS2s0PEjtKf1ijtCjHPJzVMurEDLoJUWfAT3TjQKg/JRaHWmxprhGQ== X-Received: by 2002:a17:903:2281:b0:1dc:1ca9:daf4 with SMTP id b1-20020a170903228100b001dc1ca9daf4mr5947494plh.12.1708876859473; Sun, 25 Feb 2024 08:00:59 -0800 (PST) MIME-Version: 1.0 References: <20240131083244.718579-1-syq@gcc.gnu.org> <2be4441c3a739fe4c3f7a83097270257c3fcd646.camel@xry111.site> <11a02e57-b292-4f1e-b879-a54ca08c2234@redhat.com> In-Reply-To: From: YunQiang Su Date: Mon, 26 Feb 2024 00:00:47 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] MIPS: support PCREL GOT access To: "Maciej W. Rozycki" Cc: Nick Clifton , Xi Ruoyao , binutils@sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,BODY_8BITS,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Maciej W. Rozycki =E4=BA=8E2024=E5=B9=B42=E6=9C=887=E6= =97=A5=E5=91=A8=E4=B8=89 03:48=E5=86=99=E9=81=93=EF=BC=9A > > On Wed, 7 Feb 2024, YunQiang Su wrote: > > > > The proper way to handle such verification is to tighten the test ca= ses. > > > Relocations have well-defined semantics, so you can prepare sources s= uch > > > as to get reproducible output you can then match against. That means > > > verifying exact bit patterns in files produced, and you can arrange f= or > > > boundary cases, such as carry/borrow or overflow, to be verified wher= e > > > applicable too. We have such detailed cases in our testsuite already= . > > > > > > > In fact I am worried that we use the wrong GOT slot, and the ldso > > set the GOT incorrectly for use., which is not easy to test statically. > > Bit by bit comparison is not easy, due to that the final executables > > contains something from libc, which may have quite different versions. > > You don't have to use libc at link time and using components from outsid= e > binutils is what makes compiled tests so problematic in our testsuite. W= e > avoid using external components where feasible. > > We can try and do our best to produce correctly linked executables and > shared libraries and provide testsuite coverage for what we do, and then What my plan is (although I have no idea how to archive it with dejagnu): 1. f.c int f() {return 0;} mipsel-linux-gnu-gcc -O2 -mabi=3D32 f.c -shared -o libf.so 2. f1.c extern int f(); int f1 () {return f();} mipsel-linux-gnu-gcc -O2 f1.c -shared -L. -lf -o libf1.so 3. Let's inspect libf1.so with `objdump -DTC` 3.1 We can see the symbol 'f' is in an address, 00000520. 00000520 DF *UND* 00000000 f 3.2 We can see a line "00000520 <_MIPS_STUBS_>" 3.3 We can see the address of .got is "00010570 <__TMC_END__>" 3.3 We can see " 50c: 8f998040 lw t9,-32704(gp)" in , and GOT_ADR + GP_MAGIC + LW_OFFSET =3D GOT_SLOT_OF_F 0x00010570 + 0x7ff0 + (-32704) =3D 0x105a0 3.4 The content of address GOT_SLOT_OF_F (0x105a0) is 0x00000520. @Maciej W. Rozycki Is this correct? > if you want to verify ld.so, then do it with the testsuite for the > relevant project: glibc, uClibc, musl, whatever. > > Maciej