From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by sourceware.org (Postfix) with ESMTPS id 7619F3858D20 for ; Thu, 28 Sep 2023 07:26:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7619F3858D20 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-690d2441b95so9660149b3a.1 for ; Thu, 28 Sep 2023 00:26:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695885959; x=1696490759; h=content-transfer-encoding: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=c9d69BuHjpdGFmXHyMb6StksjGSjBKLesVo2tMbDTVM=; b=E7kq+5Z1KApP1etMacUIPuzy4mUvckWwAhHitzjerjxZ/04+jJ1+0LBLYfGkwryVwR WIDkBK2xzMCt5oY0/24XnLkvMYSXtkHyyqa1gFrBFjGt+tzZd95OGJL0LZShh58Vh08l BMrV50ikMcdERI6UGpw1wIb32668Uy+Ag7EJSfF0Cm2iekaJCOalKx0XSHRJv/1bpMEr 9KNeAfxhs6wgPlQ0TKSopw7q3jT9VkhYn9i/o1U/nyJXrt6Rt1vM5Xg+XTww2YTMymFm X4/Xjn6HPCdYS7NmA5yvERAiidQcWJKg6BS2a40MJ3HBmHLhJZjzAbZaU2GMpEEaYThW N5LQ== X-Gm-Message-State: AOJu0YxckKlpMRgXMEh8ADS5HCv4F+ZwQaPYxTmzTT9te2cY3XAOyNis +wlxS9CRhEosEUBHpXsHXWl+OCBigwGnQDViNQCCTczjlVQ= X-Google-Smtp-Source: AGHT+IEr/5j96yUC8apP9SdgaIVjDBHkU5cHsPY9GDtIptpY+cwqidg052QhDnWFSBCasQ/EdWxwpBBhzRMOVe/OEXw= X-Received: by 2002:a05:6a00:1990:b0:68e:3616:604a with SMTP id d16-20020a056a00199000b0068e3616604amr818549pfl.8.1695885959340; Thu, 28 Sep 2023 00:25:59 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Max Larsson Date: Thu, 28 Sep 2023 09:25:47 +0200 Message-ID: Subject: Re: Overlapping program headers/segments To: Max Larsson via Binutils Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,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 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: > You didn't provide the linker script, which may have the observed effect = together > with your code change: If it puts .text and .rodata together, then the ov= erlap is > to be expected (as would frequently happen for NOTE segments and .note se= ctions), > I think. Forget to mention. I using a slight modified elf.sc script, but even using the plain elf.sc linker script gives me overlapping segments. But i think i found the issue/solution. Read below. >> So my question why do I get such a result, and how can I avoid it? > > If you want to avoid the overlap you need to provide enough padding > between TEXT and RODATA. See the handling of SEPARATE_CODE in > scripttempl/elf.sc. I tried that, but it doesn't give me the desired result. I need more a result delivered be enabling WRITABLE_RODATA. But a writable .rodata section isn't liked as primer solution. It's a possible the backup plan. Nevertheless your hint with SEPARATE_CODE did lead to a solution, even if I cannot reconstruct how i got there. As mention I copied the solution from elfxx-mips.c:_bfd_mips_elf_modify_segment_map to put the .rodata section in its own segment. What I wondered about was that the code just looks for the section and just puts it in a new segment, but it did not remove the section from the origin segment. Now I copied the code and adopted it from elf32-spu.c: spu_elf_modify_segment_map, which not only put the section in its own segment but even removes it from the origin segment. Doing so gives me no overlapping segments. Thus the code I used in the first place may not have used the internal data structures in the "correct" way, leaving a section somehow in two segments, which gives wrong calculated addresses and offsets? Anyway thanks for the help. kind regards Max On Mon, Sep 25, 2023 at 9:24=E2=80=AFAM Andreas Schwab wro= te: > > On Sep 24 2023, Max Larsson via Binutils wrote: > > > So my question why do I get such a result, and how can I avoid it? > > If you want to avoid the overlap you need to provide enough padding > between TEXT and RODATA. See the handling of SEPARATE_CODE in > scripttempl/elf.sc. > > -- > Andreas Schwab, SUSE Labs, schwab@suse.de > GPG Key fingerprint =3D 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D= 7 > "And now for something completely different."