From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-f46.google.com (mail-io1-f46.google.com [209.85.166.46]) by sourceware.org (Postfix) with ESMTPS id 0352D3858D32 for ; Sun, 25 Feb 2024 14:09:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0352D3858D32 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 0352D3858D32 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.166.46 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708870143; cv=none; b=nQ/STgZM/ytdd2HYXBh0FNM76VCj4yrUd1aImEF7ZjV7ulk3TWmNBQ/IcDXq0bMYlxBcXrEgoE7A39suej9I+A2Vi6HPNmuNdCvEauPCJ3qqMsQiUyni25NwuBtLVPfM8bM697WcdcGE1w9BZsrWtoSsapXo1wMmui635QWdXpM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708870143; c=relaxed/simple; bh=OrdJlHyYtQbUiaLQcnmuKU6f1K9a7THMzykjAfEFNnk=; h=MIME-Version:From:Date:Message-ID:Subject:To; b=WdBX4hbRRTxEsj1yp3Q2Rnd5vqHy1w93p/hoIEkOCwzMF4YyHEPBWEPH2rYF1nEjDqYBg47IKqDR+U+fOLiQGSxQ9wlYo0UTKQPM5RFWBPk7pQP6CxTeO3OugZjFMj+fJO3+F9rWPP/4mzUEonrYWs9cBSwCtGsVuSh7HK8auic= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-f46.google.com with SMTP id ca18e2360f4ac-7c48ef54d9bso52569939f.2 for ; Sun, 25 Feb 2024 06:09:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708870140; x=1709474940; 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=rs1viPJFBj9rz7l1fZlYjKytbao+rijpL9un8f+yTk4=; b=keaLwud5dqeXF1xomqtfybpcYy5w+YqGC4G9XkUGxzJwfjMTpLsj5D9PkYbUzwfYjn 3pzHs/pu54pCpbE/qdosPM9GHOREOZ8K7n9sBnePoTPylvk1tXNA0RhQVHNvXU4BicU4 vPczW3J62+K9czDNQ/bABJNdSWKdDvy1qkEwjwGKcXe5BU256t+tuouJlHePkti1BZ/F q/+2ErAUm/UwPI28Aox/XgvBUbYvO54Vrm5N7ItyUKysAqj2Gx6IZM6FDSVJOkKqZNGz 9OD+zoXLotO/hTm1P5HQXqFEZRzHUQw/cm5O/uHmSty84rKcymL9iEAn1zkfFf+VbMSu vTWw== X-Forwarded-Encrypted: i=1; AJvYcCXZaDNDvhJ1864iDXe2SKLjHYNyzphSrLKjVGK0bUrH7KbVvxamHf/XQ52HiOYzVuGCqEJz1Y6/Im4nZYiXFV4jYLOT5RsQrQ== X-Gm-Message-State: AOJu0YzZGc1tnfHDdMSKmH7j0EvOJQahOf+XcJa6t0N860qqvELVANok p/l1ZM2jSZji+Yu6KIbJ5ydTlkgPI5u1JlXi2Ofu/HQ8A7nqvUbEIb2/GuZ/yjs= X-Google-Smtp-Source: AGHT+IEp+mwf6xDa4+29WKoo/rlEU88h99jLGC9SaN9Vr/GgLTN/KNovOrjvDuWKDVdL8wdsqjC4kw== X-Received: by 2002:a92:3646:0:b0:363:e82b:71c with SMTP id d6-20020a923646000000b00363e82b071cmr4940528ilf.17.1708870139930; Sun, 25 Feb 2024 06:08:59 -0800 (PST) Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com. [209.85.214.171]) by smtp.gmail.com with ESMTPSA id d9-20020a631d09000000b005df58c83e89sm2408496pgd.84.2024.02.25.06.08.59 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 25 Feb 2024 06:08:59 -0800 (PST) Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1dc49b00bdbso18853725ad.3 for ; Sun, 25 Feb 2024 06:08:59 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXQjxPGvk9UtfPf8wndwIwL0kdZKiunBJpNym1AMW0tepecXOFiSYy2Dvpbm5gTHXVgfM2D/Q8/aseaj03E6qC4Q7KPw09Z8A== X-Received: by 2002:a17:902:be0a:b0:1db:de79:8664 with SMTP id r10-20020a170902be0a00b001dbde798664mr4020114pls.60.1708870139392; Sun, 25 Feb 2024 06:08:59 -0800 (PST) MIME-Version: 1.0 References: <20240221145256.3118097-1-syq@gcc.gnu.org> In-Reply-To: From: YunQiang Su Date: Sun, 25 Feb 2024 22:08:47 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v6] MIPS: Reject branch absolute relocs for PIC for linking To: "Maciej W. Rozycki" Cc: Hans-Peter Nilsson , Nick Clifton , binutils@sourceware.org, xry111@xry111.site 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=8822=E6= =97=A5=E5=91=A8=E5=9B=9B 21:13=E5=86=99=E9=81=93=EF=BC=9A > > On Thu, 22 Feb 2024, YunQiang Su wrote: > > > > > + howto =3D MIPS_ELF_RTYPE_TO_HOWTO (abfd, r_type, NE= WABI_P (abfd)); > > > > + info->callbacks->einfo > > > > + /* xgettext:c-format */ > > > > + (_("%X%H: relocation %s against `*ABS*' cannot be= used" > > > > > > There's no "*ABS*" in the source and IMHO that'd look confusing > > > to innocent users. How about "...against an absolute value"? > > > Or "...against an absolute value or absolute symbol"? Perhaps > > > the latter is a bit too wordy, but also more complete. > > > > > > > Good idea. I think that we should use "...against an absolute value". > > "absolute symbol" is not included in this code, as it's r_symndx is > > not STN_UNDEF. > > Well code says otherwise: > > + if (branch_reloc_p (r_type) && r_symndx =3D=3D STN_UNDEF) > > did you mean "the relocation's r_symndx is STN_UNDEF"? > > But it can be a relocation against an absolute symbol, for example if th= e > symbol referred to by a relocation is supplied by another module in the > link or a linker script and said symbol is absolute. This case has to be I have no idea whether we should emit this error for this case: If the symbol is set by a linker script, and is near enough with our instruction, the object should be ok for PIC? If not near enough, a "relocation truncated to fit" error will emit. > covered in testing as well, as I infer from your code it won't be handled > correctly. > > In fact this situation is not unique to branch relocations, because no > PC-relative relocation against an absolute symbol or value can be resolve= d > at link time for PIC/PIE links. So you need to make your code generic fo= r > any relocations that have the `pc_relative' flag set in their howto unles= s > we have a way to make a dynamic relocation out of such a relocation (whic= h > is none right now, as we still only have R_MIPS_REL32 as the sole dynamic > relocation, except for TLS stuff). > > Extra test cases will be appreciated if you can come up with ones. > > Maciej