public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Mark Wielaard <mark@klomp.org>
Cc: Michael Matz <matz@suse.de>, dwz@sourceware.org, jakub@redhat.com
Subject: Re: [PATCH] Add -p native and -e native
Date: Tue, 13 Apr 2021 13:15:39 +0200	[thread overview]
Message-ID: <14f3545a-12e2-9922-cd44-14dcaa5d68ee@suse.de> (raw)
In-Reply-To: <20210413100459.GJ3953@wildebeest.org>

On 4/13/21 12:04 PM, Mark Wielaard wrote:
> Hi Tom,
> 
> On Tue, Apr 13, 2021 at 10:33:16AM +0200, Tom de Vries wrote:
>> On 4/13/21 9:45 AM, Tom de Vries wrote:
>>> On 4/12/21 10:14 PM, Mark Wielaard wrote:
>>>> Why are we going through all this?
>>>>
>>>> So with this when something is build as 32bit it can use 64bit as
>>>> "native" pointer size. Or if something is cross compiled to
>>>> little-endian it can still report big-endian as "native",
>>>>
>>>
>>> Yes.  Native is defined by the current implementation as the default
>>> endiannes and pointer size of code generated by the compiler used to
>>> compile dwz.
>>>
>>> So if you're using a compiler that by default generates 32-bit while
>>> targeting 64-bit platform, then the resulting -p native is 32-bit.
>>>
>>>> But when does that ever make sense?
>>>
>>> It doesn't.
>>>
>>> The current implementation makes sense if you use a native compiler
>>> (i.e., generates 64-bit code for a 64-bit platform), and the same holds
>>> in a cross-compiling scenario.
>>>
>>> I think the assumption that was made here is that the implementation is
>>> good enough if it gives good results for the native compiler scenario.
>>>
>>>> Why would one run the 32bit
>>>> binary on a 64bit system and wanting the default -p native be 64bit
>>>> instead of 32bit? 
>>>
>>> No idea why one would want to run the 32-bit binary on a 64bit system in
>>> the first place.  But it's possible.
>>>
>>> If we have an option -p/-e native, it needs to be assigned a semantics
>>> in that case.
>>>
>>> And in the case of using a native compiler, the semantics are accurate.
>>>
>>>> Wouldn't one install and run the actual "native"
>>>> 64-bit binary in that case?
>>>
>>> Yes, that's what I would do.
> 
> So "native" is not actually needed?
> 

That's not the conclusion I draw based on the argumentation above.

>> FWIW, would this patch address your concerns?
>>
>> It adds an option -p/-e self, and when we do:
>> ...
>> $ make clean; make CFLAGS="-O2 -g -m32" LDFLAGS=-m32
>> ...
>> we have:
>> ...
>> $ ./dwz -?
>>   ...
>>   -p, --multifile-pointer-size <SIZE|auto|native|self>
>>                               Set pointer size of multifile, in number
>> of bytes.
>>                               Native pointer size is 8. Self pointer
>> size is 4.
>>                               Default value: auto.
> 
> So the semantics of "self" make sense to me, but the implementation doesn't.
> 
> My concerns are that "native" has semantics that nobody would use

I think for the use cases that are obvious, self and native have the
same semantics and users will pick either.

For the non-obvious cases, I'm not sure what usage will look like, so
I'd say the solution there is to define options with clear semantics and
let the user figure it out.

> and
> it introduces a complicated build rule for the "native.o" and defines
> based on readelf scraping.
> 
> "self" semantics make sense to me (and I would actually call that
> "native") but you don't need this complicated trick of generating an
> .o file and using readelf to create defines. You can simply use sizeof
> (void *) and #include <endian.h> plus __BYTE_ORDER to define the
> endian and pointer sizes.
> 
> So can we just have native or self based on sizeof (void *) and
> __BYTE_ORDER and get rid of this Makefile trickery?
> 

I think the current implementation is reliable.  I'm not sure about your
proposal.

Looking at the gcc sources, I find:
...
    dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Pointer Size (in bytes)");
...
and:
...
#ifndef DWARF2_ADDR_SIZE
#define DWARF2_ADDR_SIZE ((POINTER_SIZE + BITS_PER_UNIT - 1) /
BITS_PER_UNIT)
#endif
...
and then some hardcoded overrides in some targets.

I don't see any guarantee that the pointer size as used in generated
dwarf matches sizeof (void *).

So concretely, my fear is that for some target you'd compile dwz
natively, then compile some app natively, use -p self and find that the
app not matches -p self.

Thanks,
- Tom

      reply	other threads:[~2021-04-13 11:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-09  9:24 Tom de Vries
2021-04-09  9:42 ` Mark Wielaard
2021-04-09 12:48   ` Tom de Vries
2021-04-09 13:03   ` Michael Matz
2021-04-09 15:58     ` Tom de Vries
2021-04-12 12:33       ` Michael Matz
2021-04-12 15:11         ` Tom de Vries
2021-04-12 19:53           ` [committed] " Tom de Vries
2021-04-12 20:14       ` [PATCH] " Mark Wielaard
2021-04-13  7:45         ` Tom de Vries
2021-04-13  8:33           ` Tom de Vries
2021-04-13 10:04             ` Mark Wielaard
2021-04-13 11:15               ` Tom de Vries [this message]

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=14f3545a-12e2-9922-cd44-14dcaa5d68ee@suse.de \
    --to=tdevries@suse.de \
    --cc=dwz@sourceware.org \
    --cc=jakub@redhat.com \
    --cc=mark@klomp.org \
    --cc=matz@suse.de \
    /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).