From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) by sourceware.org (Postfix) with ESMTPS id C096A385DC00 for ; Wed, 3 Jun 2020 01:29:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C096A385DC00 Received: by mail-io1-xd43.google.com with SMTP id c8so437640iob.6 for ; Tue, 02 Jun 2020 18:29:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7cIrhn9Gsl+VTKClu1qGMqtUVK+Ihv/XcI2DYBC1rD8=; b=eQbj9iZJDOixCpQfZswIKmvy3ZbYXzx+yBMNEzBrBZn5bO9G2M/6agPm6ytz5loTpR T8gHleF+wy7IOFC+BiSA/LUepkrxzoqzZqK+kNb5xUYjpk1dZfnE8LvUPsAdIKYBtGXk EA9Ef3d4fgc5COEpcfZ+m5J9NIUXz/RjUBX+gjy4cDpArPl8fsiRWgC1BIHjaCLGEZ68 yvhNaMd/oRwB04/QL+z7R+Me+XmjwOsE208oFm9YpRMY7LwTB4T2qDSE556oLDgK/9Zg opmu6Tmwh1Wn6AnkeqxtQhyH03w1HmFtMybDERI4RXgECjSp0Kew66vq/rk7lEzt9X7N Ak0A== X-Gm-Message-State: AOAM530Zr3jB0gDTNcuNJ5Jj4vPbIlzLDNyxNJfSW8IgztUmlWdrxFCH wF7GOivrh0BXJ6FGXirC8fS2kFxm+w0aKeR0NaZ7e6lJ X-Google-Smtp-Source: ABdhPJxJapKlM2zY46C07u12GMISW15nY7SwXHQbKjKEDXxViVz4Xub1rljoLPmAX8jYKZwx1XXxzvdbGr7tbT/jf8E= X-Received: by 2002:a6b:39c3:: with SMTP id g186mr1672373ioa.91.1591147792228; Tue, 02 Jun 2020 18:29:52 -0700 (PDT) MIME-Version: 1.0 References: <20200602203831.286979-1-hjl.tools@gmail.com> In-Reply-To: From: "H.J. Lu" Date: Tue, 2 Jun 2020 18:29:16 -0700 Message-ID: Subject: Re: [PATCH] ELF: Don't check relocations in non-loaded, non-alloced sections To: Fangrui Song Cc: Binutils Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jun 2020 01:29:53 -0000 On Tue, Jun 2, 2020 at 5:06 PM Fangrui Song wrote: > > I haven't really read the patch, but just wanted to express a point. > It is sometimes useful to check relocations even for a non-SHF_ALLOC > section. For example, a PC relative relocation type does not make > sense from a non-SHF_ALLOC section referencing a SHF_ALLOC section. > > Conceptually, even if a non-SHF_ALLOC is loaded as part of the memory > image, the distance between it and a SHF_ALLOC section may not be a > constant, so the linker cannot reasonably resolve the relocation. > Since non-SHF_ALLOC sections have no impact on run-time behavior, ld.so ignores dynamic relocations on non-SHF_ALLOC section. In checking phase, relocations on non-SHF_ALLOC section shouldn't alter other relocatitons against the same symbol. When resolving such relocations, linker should ignore any relocation errors for such relocations. -- H.J.