public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc generated memcpy calls symbol version
@ 2018-01-26 20:30 Tom Mason
  2018-01-26 20:37 ` H.J. Lu
  2018-01-29 20:05 ` Andi Kleen
  0 siblings, 2 replies; 7+ messages in thread
From: Tom Mason @ 2018-01-26 20:30 UTC (permalink / raw)
  To: gcc

Hi,
I've got a project here: https://github.com/wheybags/glibc_version_header
which uses .symver directives to link to a specified version of glibc, so
long as it's older than the version on your system.
This works, but a problem I'm having is that gcc itself will sometimes
insert calls to memcpy (or memmove, memset and memcmp), as documented here:
https://gcc.gnu.org/onlinedocs/gcc/Standards.html
When it does so, it doesn't respect the .symver directives, and uses the
default version.
Is there any way for me to force the version for these symbols aswell?
I'm aware that I can disable the whole mechanism with -freestanding, but I
don't want to cripple the optimiser.
Regards,
Tom Mason

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gcc generated memcpy calls symbol version
  2018-01-26 20:30 gcc generated memcpy calls symbol version Tom Mason
@ 2018-01-26 20:37 ` H.J. Lu
  2018-01-26 21:17   ` Tom Mason
  2018-01-29 20:05 ` Andi Kleen
  1 sibling, 1 reply; 7+ messages in thread
From: H.J. Lu @ 2018-01-26 20:37 UTC (permalink / raw)
  To: Tom Mason; +Cc: GCC Development

On Fri, Jan 26, 2018 at 12:29 PM, Tom Mason <wheybags@wheybags.com> wrote:
> Hi,
> I've got a project here: https://github.com/wheybags/glibc_version_header
> which uses .symver directives to link to a specified version of glibc, so
> long as it's older than the version on your system.
> This works, but a problem I'm having is that gcc itself will sometimes
> insert calls to memcpy (or memmove, memset and memcmp), as documented here:
> https://gcc.gnu.org/onlinedocs/gcc/Standards.html
> When it does so, it doesn't respect the .symver directives, and uses the
> default version.
> Is there any way for me to force the version for these symbols aswell?
> I'm aware that I can disable the whole mechanism with -freestanding, but I
> don't want to cripple the optimiser.

I think this is related to:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67220

-- 
H.J.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gcc generated memcpy calls symbol version
  2018-01-26 20:37 ` H.J. Lu
@ 2018-01-26 21:17   ` Tom Mason
  2018-01-26 21:22     ` H.J. Lu
  0 siblings, 1 reply; 7+ messages in thread
From: Tom Mason @ 2018-01-26 21:17 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GCC Development

I'm not entirely sure I understand that issue. From what I understand,
calls to a function in a shared library should always use the PLT?
Also, I don't understand the purpose of applying hidden visibility to an
extern symbol,
But anyway, doesn't matter terribly much if I understand :p

On Fri, Jan 26, 2018 at 8:37 PM, H.J. Lu <hjl.tools@gmail.com> wrote:

> On Fri, Jan 26, 2018 at 12:29 PM, Tom Mason <wheybags@wheybags.com> wrote:
> > Hi,
> > I've got a project here: https://github.com/wheybags/
> glibc_version_header
> > which uses .symver directives to link to a specified version of glibc, so
> > long as it's older than the version on your system.
> > This works, but a problem I'm having is that gcc itself will sometimes
> > insert calls to memcpy (or memmove, memset and memcmp), as documented
> here:
> > https://gcc.gnu.org/onlinedocs/gcc/Standards.html
> > When it does so, it doesn't respect the .symver directives, and uses the
> > default version.
> > Is there any way for me to force the version for these symbols aswell?
> > I'm aware that I can disable the whole mechanism with -freestanding, but
> I
> > don't want to cripple the optimiser.
>
> I think this is related to:
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67220
>
> --
> H.J.
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gcc generated memcpy calls symbol version
  2018-01-26 21:17   ` Tom Mason
@ 2018-01-26 21:22     ` H.J. Lu
  2018-01-27 13:26       ` Tom Mason
  0 siblings, 1 reply; 7+ messages in thread
From: H.J. Lu @ 2018-01-26 21:22 UTC (permalink / raw)
  To: Tom Mason; +Cc: GCC Development

On Fri, Jan 26, 2018 at 1:17 PM, Tom Mason <wheybags@wheybags.com> wrote:
> I'm not entirely sure I understand that issue. From what I understand, calls
> to a function in a shared library should always use the PLT?
> Also, I don't understand the purpose of applying hidden visibility to an
> extern symbol,

There is no need for PLT since hidden symbol is defined locally.  But
GCC ignores hidden visibility for libcalls, like memcpy.  If GCC treats
them like normal calls, your scheme and my testcase should work.


> But anyway, doesn't matter terribly much if I understand :p
>
> On Fri, Jan 26, 2018 at 8:37 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>
>> On Fri, Jan 26, 2018 at 12:29 PM, Tom Mason <wheybags@wheybags.com> wrote:
>> > Hi,
>> > I've got a project here:
>> > https://github.com/wheybags/glibc_version_header
>> > which uses .symver directives to link to a specified version of glibc,
>> > so
>> > long as it's older than the version on your system.
>> > This works, but a problem I'm having is that gcc itself will sometimes
>> > insert calls to memcpy (or memmove, memset and memcmp), as documented
>> > here:
>> > https://gcc.gnu.org/onlinedocs/gcc/Standards.html
>> > When it does so, it doesn't respect the .symver directives, and uses the
>> > default version.
>> > Is there any way for me to force the version for these symbols aswell?
>> > I'm aware that I can disable the whole mechanism with -freestanding, but
>> > I
>> > don't want to cripple the optimiser.
>>
>> I think this is related to:
>>
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67220
>>
>> --
>> H.J.
>
>



-- 
H.J.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gcc generated memcpy calls symbol version
  2018-01-26 21:22     ` H.J. Lu
@ 2018-01-27 13:26       ` Tom Mason
  0 siblings, 0 replies; 7+ messages in thread
From: Tom Mason @ 2018-01-27 13:26 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GCC Development

Actually, never mind, it's working fine:
https://gist.github.com/wheybags/b7e4152daf76c72503e9e1f52f3dca3d and I
have some other problem.


On Fri, Jan 26, 2018 at 9:22 PM, H.J. Lu <hjl.tools@gmail.com> wrote:

> On Fri, Jan 26, 2018 at 1:17 PM, Tom Mason <wheybags@wheybags.com> wrote:
> > I'm not entirely sure I understand that issue. From what I understand,
> calls
> > to a function in a shared library should always use the PLT?
> > Also, I don't understand the purpose of applying hidden visibility to an
> > extern symbol,
>
> There is no need for PLT since hidden symbol is defined locally.  But
> GCC ignores hidden visibility for libcalls, like memcpy.  If GCC treats
> them like normal calls, your scheme and my testcase should work.
>
>
> > But anyway, doesn't matter terribly much if I understand :p
> >
> > On Fri, Jan 26, 2018 at 8:37 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> >>
> >> On Fri, Jan 26, 2018 at 12:29 PM, Tom Mason <wheybags@wheybags.com>
> wrote:
> >> > Hi,
> >> > I've got a project here:
> >> > https://github.com/wheybags/glibc_version_header
> >> > which uses .symver directives to link to a specified version of glibc,
> >> > so
> >> > long as it's older than the version on your system.
> >> > This works, but a problem I'm having is that gcc itself will sometimes
> >> > insert calls to memcpy (or memmove, memset and memcmp), as documented
> >> > here:
> >> > https://gcc.gnu.org/onlinedocs/gcc/Standards.html
> >> > When it does so, it doesn't respect the .symver directives, and uses
> the
> >> > default version.
> >> > Is there any way for me to force the version for these symbols aswell?
> >> > I'm aware that I can disable the whole mechanism with -freestanding,
> but
> >> > I
> >> > don't want to cripple the optimiser.
> >>
> >> I think this is related to:
> >>
> >> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67220
> >>
> >> --
> >> H.J.
> >
> >
>
>
>
> --
> H.J.
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gcc generated memcpy calls symbol version
  2018-01-26 20:30 gcc generated memcpy calls symbol version Tom Mason
  2018-01-26 20:37 ` H.J. Lu
@ 2018-01-29 20:05 ` Andi Kleen
  2018-01-30  8:03   ` Tom Mason
  1 sibling, 1 reply; 7+ messages in thread
From: Andi Kleen @ 2018-01-29 20:05 UTC (permalink / raw)
  To: Tom Mason; +Cc: gcc

Tom Mason <wheybags@wheybags.com> writes:

> Is there any way for me to force the version for these symbols aswell?

It seems pointless because the ABI for these symbols will never change.

-Andi

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gcc generated memcpy calls symbol version
  2018-01-29 20:05 ` Andi Kleen
@ 2018-01-30  8:03   ` Tom Mason
  0 siblings, 0 replies; 7+ messages in thread
From: Tom Mason @ 2018-01-30  8:03 UTC (permalink / raw)
  To: Andi Kleen; +Cc: GCC Development

Well, as I said, I was mistaken and the .symver directive does actually
work for this, but the point of forcing the version is to provide a
backwards compatible binary. If I compile with GCC on a modern system, it
might generate a call to memcpy@GLIBC_2.14, so then that binary won't run
on a system with glibc 2.13 installed. If I force it to an earlier version
however, then it'll work just fine.

On Jan 29, 2018 9:05 PM, "Andi Kleen" <ak@linux.intel.com> wrote:

> Tom Mason <wheybags@wheybags.com> writes:
>
> > Is there any way for me to force the version for these symbols aswell?
>
> It seems pointless because the ABI for these symbols will never change.
>
> -Andi
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-01-30  8:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-26 20:30 gcc generated memcpy calls symbol version Tom Mason
2018-01-26 20:37 ` H.J. Lu
2018-01-26 21:17   ` Tom Mason
2018-01-26 21:22     ` H.J. Lu
2018-01-27 13:26       ` Tom Mason
2018-01-29 20:05 ` Andi Kleen
2018-01-30  8:03   ` Tom Mason

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).