From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by sourceware.org (Postfix) with ESMTPS id 548203858D28 for ; Wed, 18 Jan 2023 22:00:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 548203858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-il1-x131.google.com with SMTP id f8so260659ilj.5 for ; Wed, 18 Jan 2023 14:00:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=Ve2oRA9qX9S7R5miEAUmrDhkM9UWWCYnz9kJc8XXCg0=; b=Atgwb1M0gI1YqWCxkjCfZIXtUJlyydd5Fz1GfJyhrAkBStBrin9FDXSs4N7KDWF2IS ZB7VIXNG+VmJsOyJQdDRit5PwxFEomzo7C0kFOfEFs4d+4132J4uvAJYw7Pli6dHIwAr +5WOKgiAgP+sGSdDjeqI6wzd6oYH/NiSs+zi3d1bHmIpn7VkxD9UQxo2eDQsMSJaczpZ w5o0/pL+jrygu1iA7asvHrkLaVGiim7kalF4tDkzVHuZHOoweuCytj2JDjAlCqVoeFWe tCm3rS1ndo62hc6/HDebI0sayNAXGoFDeIyGoMCwMbd4UTXd6n3uVsj4HQRpiO/bHDwM KUnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Ve2oRA9qX9S7R5miEAUmrDhkM9UWWCYnz9kJc8XXCg0=; b=znWco1YlOlnvm0h7iepS9CLJpw7RtRtaS1ls3yAWEb1VahkMCvUmZE5i9yV9qrbYUo bkrgy8Hkpn/6cfdU+6QETYi7D05KX4/jl5pooWoyo+en2dOy2oz22F0HumTKgg9WS7EB QgH63TiMHEngRO5w/xt3VG/zVUggq1K+qReeJkRRgfkx/zGW6xD0yIH4vDSkVriGMlkv /0w1InOw7H5OIXM1bmL+lTCGXYMPVpr8zo7xHuhv2NswtWipFfBknz6Cu+ahmZ6NfxCy rW/TOWp7ATSgs0PYqUZnsTD2YgZjnEqUBVuTxkU3uqqYF6RTsKy8AUMKqXwqoL0sN1Iy /xlA== X-Gm-Message-State: AFqh2kp2t9Dtb0kSrkI/eIxbBe69sfs3nA/b9Uz1TysuuQ3V02gP8qzj FFYyrh738Pzeps5Pgtxgi6jxiQ== X-Google-Smtp-Source: AMrXdXs7RJVJ2EH62CFDJDN0fEDw3fUtR+6vyfDqGhqmzYD0+kzZkts1GKZy4QmHJNOZJTZVo1jpfQ== X-Received: by 2002:a92:dd0d:0:b0:30e:f9ca:8a28 with SMTP id n13-20020a92dd0d000000b0030ef9ca8a28mr7294273ilm.5.1674079209298; Wed, 18 Jan 2023 14:00:09 -0800 (PST) Received: from murgatroyd (97-122-76-186.hlrn.qwest.net. [97.122.76.186]) by smtp.gmail.com with ESMTPSA id f94-20020a0284e7000000b00389d02a032dsm10350228jai.172.2023.01.18.14.00.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 14:00:08 -0800 (PST) From: Tom Tromey To: Simon Marchi Cc: Tom Tromey , gdb-patches@sourceware.org Subject: Re: [PATCH 2/6] Set section indices when symbols are made References: <20230118153025.342512-1-tromey@adacore.com> <20230118153025.342512-3-tromey@adacore.com> <66028b75-1c70-9845-0923-9892b982211c@simark.ca> X-Attribution: Tom Date: Wed, 18 Jan 2023 15:00:07 -0700 In-Reply-To: <66028b75-1c70-9845-0923-9892b982211c@simark.ca> (Simon Marchi's message of "Wed, 18 Jan 2023 16:43:24 -0500") Message-ID: <87tu0nzeoo.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: >>>>> "Simon" == Simon Marchi writes: Simon> On 1/18/23 10:30, Tom Tromey via Gdb-patches wrote: >> Most places in gdb that create a new symbol will apply a section >> offset to the address. It seems to me that the choice of offset here >> is also an implicit choice of the section. This is particularly true >> if you examine fixup_section, which notes that it must be called >> before such offsets are applied -- meaning that if any such call has >> an effect, it's purely by accident. >> >> This patch cleans up this area by tracking the section index and >> applying it to a symbol when the address is set. This is done for >> nearly every case -- the remaining cases will be handled in later >> patches. Simon> So, if I rephrase it to make sure I understand: it's not logical to Simon> apply the relocation to the symbol's address, without also setting the Simon> symbol's section index, because the symbol's relocation value comes from Simon> the section. Does that sound right? Yes, that's right. Hypothetically, if you had a runtime linker that applied different offsets to different sections (like, text gets +0x1000, data gets +0x2000, bss gets +0x3000), then the code that applies these offsets could sometimes be wrong. But, since it's been this way a long time and, AFAIK, there aren't problems with it, then IMO it follows that setting the section from these choices is fine. One other oddity I found here is that I don't think any code uses anything other than SECT_OFF_TEXT for functions. So maybe the code to deal with the section index in a compunit symtab is not actually needed. Tom