public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Fangrui Song <i@maskray.me>
To: mengqinggang <mengqinggang@loongson.cn>, hejinyang@loongson.cn
Cc: Alan Modra <amodra@gmail.com>,
	binutils@sourceware.org, xuchenghua@loongson.cn,
	 chenglulu@loongson.cn, liuzhensong@loongson.cn,
	cailulu@loongson.cn,  xry111@xry111.site, i.swmail@xen0n.name,
	maskray@google.com,  luweining@loongson.cn, wanglei@loongson.cn
Subject: Re: [PATCH v2] BFD: Fix the bug of R_LARCH_AGLIN caused by discard section
Date: Fri, 19 Apr 2024 10:52:25 -0700	[thread overview]
Message-ID: <DS7PR12MB57651DF71DD84560F89EAFE2CB0D2@DS7PR12MB5765.namprd12.prod.outlook.com> (raw)
In-Reply-To: <3f357195-d95d-4215-cbfb-d9259f660d45@loongson.cn>

> > On Thu, Apr 18, 2024 at 11:04 PM Fangrui Song <i@maskray.me> wrote:
> > I should make it clear that I think this R_LARCH_ALIGN referencing
> > STT_SECTION with addend align+256*align_limit representation is
> > questionable.
> > Why do you break the regular semantics of STT_SECTION relocatable linking?
> >
> > Can an absolute symbol be used instead?
> Here just some my thoughts about ABS symbol. It cause more symbol cost
> in the "*.o" files. For ABS symbols, if several "*.o" files are linked
> together, there will be several extra symbols. Llvm works OK by creating
> ABS symbol (I tried, but forgot the details), but GNU AS is not. Because
> it applies its ABS value to addend (, Qinggang has investigated before.).

Elf64_Sym is relatively smaller with just 24 bytes (unlike other
control structures in ELF).
To bypass a specific oddity in relocatable linking, consider using a
SHN_ABS symbol.

You can define a SHN_ABS STB_GLOBAL STV_HIDDEN symbol to avoid
redundant copies within the link unit.
Duplicate SHN_ABS symbols of the same st_value do not cause duplicate
symbol definitions (except mold).
Alternatively, use STB_WEAK to make the deduplication intention clearer.

> > On Fri, Mar 22, 2024 at 1:29 AM mengqinggang <mengqinggang@loongson.cn> wrote:
> > I just saw this was pushed as commit daeda14191c1710ce967259a47ef4e0a3fb6eebf.
> >
> > The addition of the generic elf_backend_is_rela_normal flag seems like
> > something a global maintainer should take a closer look at.
> > In particular, I'm curious if Alan, the author of the "rela_normal"
> > commit (b491616acb5462a3694160ffef6413c160fed10a), has any thoughts on
> > this.
> >
> > The idea appears to be
> > (https://github.com/loongson/la-abi-specs/blob/release/laelf.adoc#:~:text=R_LARCH_ALIGN)
> >
> > .text
> > break 1
> > .p2align 4, , 8  // R_LARCH_ALIGN .text+0x0804
> > break 8
> >
> > In a relocatable link, the addend associated with the STT_SECTION
> > symbol is kept unchanged.
>
> Relocatable link merge input file text sections into one text section.
> If a relocation reference a section symbol, the addend would add the
> section offset in the final one text section.

This is exactly my concern. Using a STT_SECTION symbol requires a special case.

https://inbox.sourceware.org/binutils/20020506132720.GT3698@bubble.sa.bigpond.net.au/
specifies

> mips is the fly in the ointment here, and the reason for elf_backend_rela_normal.

!rela_normal is weird, and we should not introduce more weird stuff
(R_LARCH_ALIGN referencing STT_SECTION).

  reply	other threads:[~2024-04-19 17:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-22  8:29 mengqinggang
2024-04-19  6:04 ` Fangrui Song
     [not found] ` <CAN30aBHJen+LBPvSGhbgpFZsHB5CgDdp1TcGB1DgiRa6ZyG7hQ@mail.gmail.com>
2024-04-19  6:16   ` Fangrui Song
2024-04-19  8:05     ` Jinyang He
     [not found] ` <DS7PR12MB5765652E1B142D51C3BC88B1CB0D2@DS7PR12MB5765.namprd12.prod.outlook.com>
2024-04-19 14:02   ` mengqinggang
2024-04-19 17:52     ` Fangrui Song [this message]
     [not found]     ` <DS7PR12MB57658BF4F8A3BB985411FE51CB0D2@DS7PR12MB5765.namprd12.prod.outlook.com>
2024-04-30 11:30       ` mengqinggang
2024-05-01  4:06         ` Fangrui Song
     [not found]         ` <CAN30aBGUsRtSo-mY7ZeVvMLe06E6rBZjWgypg+3thmvi2uOa5g@mail.gmail.com>
2024-05-16  0:19           ` Fangrui Song
     [not found]           ` <DS7PR12MB5765981A7461D751519DF440CBED2@DS7PR12MB5765.namprd12.prod.outlook.com>
2024-05-16  7:09             ` mengqinggang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DS7PR12MB57651DF71DD84560F89EAFE2CB0D2@DS7PR12MB5765.namprd12.prod.outlook.com \
    --to=i@maskray.me \
    --cc=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=cailulu@loongson.cn \
    --cc=chenglulu@loongson.cn \
    --cc=hejinyang@loongson.cn \
    --cc=i.swmail@xen0n.name \
    --cc=liuzhensong@loongson.cn \
    --cc=luweining@loongson.cn \
    --cc=maskray@google.com \
    --cc=mengqinggang@loongson.cn \
    --cc=wanglei@loongson.cn \
    --cc=xry111@xry111.site \
    --cc=xuchenghua@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).