public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Zack Weinberg <zackw@panix.com>
Cc: GNU C Library <libc-alpha@sourceware.org>
Subject: Re: [PATCH 6/9] Add __vsyslog_internal, with same flags as __v*printf_internal.
Date: Tue, 13 Mar 2018 13:50:00 -0000	[thread overview]
Message-ID: <00551dd1-7308-51b8-11b0-f56b75810417@redhat.com> (raw)
In-Reply-To: <CAKCAbMgaLtUx3b_Wio5pz6dxL9Lc+YXM0F7CCTP_vV9GviQ87A@mail.gmail.com>

On 03/13/2018 02:37 PM, Zack Weinberg wrote:
> On Tue, Mar 13, 2018 at 8:43 AM, Florian Weimer <fweimer@redhat.com> wrote:
>> On 03/13/2018 01:39 PM, Zack Weinberg wrote:
>>>
>>> On Tue, Mar 13, 2018 at 7:59 AM, Florian Weimer <fweimer@redhat.com>
>>> wrote:
>>>>
>>>> On 03/07/2018 08:32 PM, Zack Weinberg wrote:
>>>>
>>>>> +/* __vsyslog_internal uses the same mode_flags bits as
>>>>> +   __v*printf_internal; see libio/libioP.h.  */
>>>>> +extern void __vsyslog_internal (int pri, const char *fmt,
>>>>> __gnuc_va_list
>>>>> ap,
>>>>> +                                unsigned int mode_flags)
>>>>> +     __attribute__ ((__format__ (__printf__, 2, 0)));
>>>>
>>>>
>>>>
>>>> I'm surprised that this doesn't need attribute_hidden or
>>>> libc_hidden_proto
>>>> to avoid new PLT calls.
>>>
>>>
>>> That's only needed for functions that will be called _both_ from
>>> inside and outside glibc.  This function is only ever called from
>>> inside glibc, so it doesn't appear in any Versions files and it's
>>> hidden by default.
>>
>>
>> Some architectures will still use indirect calls without attribute_hidden,
>> so please add it.  The existing tests do not catch this reliably
>> unfortunately.
> 
> Can you be more specific?  This will affect all of the other new
> __*_internal functions added in this patchset, so I need to know how
> to be sure I got it right.  Also, this seems like something we should
> find a way to automate if at all possible.

Consider this code:

$ cat call.c
int external (void) ATTR;

int
call (void)
{
   return external () + 1;
}

With default visibility, GCC 7 produces:

$ ppc64-linux-gnu-gcc -m32 -fPIC -c -O2 -DATTR= call.c && 
ppc64-linux-gnu-objdump -d --reloc call.o

call.o:     file format elf32-powerpc


Disassembly of section .text:

00000000 <call>:
    0:	94 21 ff e0 	stwu    r1,-32(r1)
    4:	7c 08 02 a6 	mflr    r0
    8:	42 9f 00 05 	bcl     20,4*cr7+so,c <call+0xc>
    c:	93 c1 00 18 	stw     r30,24(r1)
   10:	7f c8 02 a6 	mflr    r30
   14:	90 01 00 24 	stw     r0,36(r1)
   18:	3f de 00 00 	addis   r30,r30,0
			1a: R_PPC_REL16_HA	.got2+0x800e
   1c:	3b de 00 00 	addi    r30,r30,0
			1e: R_PPC_REL16_LO	.got2+0x8012
   20:	48 00 00 01 	bl      20 <call+0x20>
			20: R_PPC_PLTREL24	external+0x8000
   24:	80 01 00 24 	lwz     r0,36(r1)
   28:	83 c1 00 18 	lwz     r30,24(r1)
   2c:	38 21 00 20 	addi    r1,r1,32
   30:	38 63 00 01 	addi    r3,r3,1
   34:	7c 08 03 a6 	mtlr    r0
   38:	4e 80 00 20 	blr

With hidden visibility, we get instead:

$ ppc64-linux-gnu-gcc -m32 -fPIC -c -O2 -DATTR='__attribute ((visibility 
("hidden")))' call.c && ppc64-linux-gnu-objdump -d --reloc call.o

call.o:     file format elf32-powerpc


Disassembly of section .text:

00000000 <call>:
    0:	94 21 ff e0 	stwu    r1,-32(r1)
    4:	7c 08 02 a6 	mflr    r0
    8:	93 c1 00 18 	stw     r30,24(r1)
    c:	90 01 00 24 	stw     r0,36(r1)
   10:	48 00 00 01 	bl      10 <call+0x10>
			10: R_PPC_LOCAL24PC	external
   14:	80 01 00 24 	lwz     r0,36(r1)
   18:	83 c1 00 18 	lwz     r30,24(r1)
   1c:	38 21 00 20 	addi    r1,r1,32
   20:	38 63 00 01 	addi    r3,r3,1
   24:	7c 08 03 a6 	mtlr    r0
   28:	4e 80 00 20 	blr

The linker may have some optimization to eliminate the PLT indirection 
(blinding the localplt test), but it cannot get rid of the other 
unnecessary instructions.

Does this example help?

Thanks,
Florian

  reply	other threads:[~2018-03-13 13:50 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-07 19:32 [PATCH 0/9] Use more flags parameters instead of global bits in stdio Zack Weinberg
2018-03-07 19:32 ` [PATCH 8/9] Use PRINTF_LDBL_IS_DBL instead of __ldbl_is_dbl Zack Weinberg
2018-03-07 19:32 ` [PATCH 3/9] Use SCANF_ISOC99_A instead of _IO_FLAGS2_SCANF_STD Zack Weinberg
2018-03-26 15:35   ` Gabriel F. T. Gomes
2018-03-07 19:32 ` [PATCH 2/9] Add __vfscanf_internal and __vfwscanf_internal with flags arguments Zack Weinberg
2018-03-13 12:35   ` Adhemerval Zanella
2018-06-29 14:04     ` Florian Weimer
2018-03-26 15:28   ` Gabriel F. T. Gomes
2018-06-29 14:12     ` Florian Weimer
2018-06-29 14:24   ` Florian Weimer
2018-06-29 14:29   ` Florian Weimer
2018-03-07 19:32 ` [PATCH 4/9] Use SCANF_LDBL_IS_DBL instead of __ldbl_is_dbl Zack Weinberg
2018-03-14 12:22   ` Florian Weimer
2018-03-26 15:36   ` Gabriel F. T. Gomes
2018-03-07 19:32 ` [PATCH 5/9] Add __v*printf_internal with flags arguments Zack Weinberg
2018-03-26 15:41   ` Gabriel F. T. Gomes
2018-03-07 19:32 ` [PATCH 1/9] Use STRFMON_LDBL_IS_DBL instead of __ldbl_is_dbl Zack Weinberg
2018-03-12 20:36   ` Adhemerval Zanella
2018-03-12 21:11     ` Zack Weinberg
2018-03-13 11:45       ` Adhemerval Zanella
2018-03-26 15:17   ` Gabriel F. T. Gomes
2018-03-26 15:40     ` Zack Weinberg
2018-03-26 15:52       ` Gabriel F. T. Gomes
2018-03-07 19:32 ` [PATCH 6/9] Add __vsyslog_internal, with same flags as __v*printf_internal Zack Weinberg
2018-03-13 11:59   ` Florian Weimer
2018-03-13 12:39     ` Zack Weinberg
2018-03-13 12:43       ` Florian Weimer
2018-03-13 13:37         ` Zack Weinberg
2018-03-13 13:50           ` Florian Weimer [this message]
2018-03-13 14:11             ` Zack Weinberg
2018-03-13 14:13               ` Florian Weimer
2018-03-07 19:51 ` [PATCH 9/9] Post-cleanup: don't include math.h/math_private.h in math_ldbl_opt.h Zack Weinberg
2018-03-07 19:51 ` [PATCH 7/9] Use PRINTF_FORTIFY instead of _IO_FLAGS2_FORTIFY Zack Weinberg
2018-03-12 15:29 ` [PATCH 0/9] Use more flags parameters instead of global bits in stdio Zack Weinberg
2018-03-26 15:16 ` Gabriel F. T. Gomes
2018-03-26 15:47   ` Zack Weinberg
2018-06-27 15:50 ` Florian Weimer

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=00551dd1-7308-51b8-11b0-f56b75810417@redhat.com \
    --to=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=zackw@panix.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).