public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Fangrui Song <i@maskray.me>
To: Jan Beulich <jbeulich@suse.com>
Cc: binutils@sourceware.org, Alan Modra <amodra@gmail.com>,
	Nick Clifton <nickc@redhat.com>
Subject: Re: [PATCH] gas: copy st_size only if unset
Date: Thu, 31 Mar 2022 18:33:43 -0700	[thread overview]
Message-ID: <20220401013343.jeb5ptalaumk7cdq@gmail.com> (raw)
In-Reply-To: <2b2801ff-0bc4-2680-2526-74dd87be3ea0@suse.com>

On 2022-03-31, Jan Beulich wrote:
>On 31.03.2022 05:37, Fangrui Song wrote:
>> For
>> ```
>> .size foo1, 1
>> foo1:
>>
>> .set bar1, foo1
>> .size bar1, 2
>> .size bar2, 2
>> .set bar2, foo1
>>
>> .set bar3, foo2
>> .size bar3, 2
>> .size bar4, 2
>> .set bar4, foo2
>>
>> .size foo2, 1
>> foo2:
>> ```
>>
>> bar1's size is 2 while bar2, bar3, bar4's is 1. The behavior of bar1 makes sense
>> (generally directives on the new symbol should win) and is relied upon by glibc
>> stdio-common/errlist.c:
>
>But what about
>
>foo1:
>	.size foo1, 1
>foo2:
>	.size foo2, 2
>	.set bar, foo1
>	.set bar, foo2
>
>I would think bar's size should end up being 2 in this case, whereas I
>think it would end up being 1 with your change.
>
>Jan

bar's size is 2. The patch has no effect, because `dest` variables for the two
invocations are (surprisingly) different!

bar is a volatile symbol (created by .set instead of .equiv). The
second .set directive creates calls gas.c/read.c:3273 symbol_clone (symbolP, 1).

That said, I think it makes sense to add tests for this as well.
I'll use the following if this patch is accepted.

   .text
   
   .size foo1, 1
   foo1:
   
   .set bar1, foo1
   .size bar1, 2
   .size bar2, 2
   .set bar2, foo1
   
   .set bar3, foo2
   .size bar3, 2
   .size bar4, 2
   .set bar4, foo2
   
   .set bar5, foo1
   .set bar6, foo2
   
   .size foo2, 3
   foo2:
   
   .set bar7, foo1
   .set bar7, foo2

  reply	other threads:[~2022-04-01  1:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-31  3:37 Fangrui Song
2022-03-31  6:22 ` Jan Beulich
2022-04-01  1:33   ` Fangrui Song [this message]
2022-04-04 11:27     ` Jan Beulich
2022-04-08  7:42     ` Alan Modra
2022-04-08 21:26       ` Fangrui Song
2022-04-08 23:01         ` Fangrui Song
2022-04-08 23:06           ` Fangrui Song
2022-04-09  1:12           ` Alan Modra
2022-04-09  0:43         ` Alan Modra
2022-04-09  4:29         ` Jeff Law

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=20220401013343.jeb5ptalaumk7cdq@gmail.com \
    --to=i@maskray.me \
    --cc=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=jbeulich@suse.com \
    --cc=nickc@redhat.com \
    /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).