Message ID | 1489671790-7611-2-git-send-email-adhemerval.zanella@linaro.org |
---|---|
State | New |
Headers | show |
Series | [1/2] Build divdi3 only for architecture that required it | expand |
On 03/16/2017 02:43 PM, Adhemerval Zanella wrote: > To avoid it, this patch uses the linker option --wrap to replace all > the internal libc.so .udiv calls to the wrapper __wrap_.udiv. Along > with strong alias in the udiv implementations, it makes linker do > local calls. I think we already use a different mechanism for a similar purpose, via sysdeps/generic/symbol-hacks.h. Maybe it's possible to reuse that? Thanks, Florian
On 16/03/2017 11:45, Florian Weimer wrote: > On 03/16/2017 02:43 PM, Adhemerval Zanella wrote: >> To avoid it, this patch uses the linker option --wrap to replace all >> the internal libc.so .udiv calls to the wrapper __wrap_.udiv. Along >> with strong alias in the udiv implementations, it makes linker do >> local calls. > > I think we already use a different mechanism for a similar purpose, via sysdeps/generic/symbol-hacks.h. Maybe it's possible to reuse that? > > Thanks, > Florian The problem is now that divdi3 is not provided by glibc anymore we can't use the same trick since __divdi3 and __moddi3 will be provided by libgcc. Another way to actually redefine .udiv is to either still keep using divdi3 for sparc32 .
On 16/03/2017 13:59, Adhemerval Zanella wrote: > > > On 16/03/2017 11:45, Florian Weimer wrote: >> On 03/16/2017 02:43 PM, Adhemerval Zanella wrote: >>> To avoid it, this patch uses the linker option --wrap to replace all >>> the internal libc.so .udiv calls to the wrapper __wrap_.udiv. Along >>> with strong alias in the udiv implementations, it makes linker do >>> local calls. >> >> I think we already use a different mechanism for a similar purpose, via sysdeps/generic/symbol-hacks.h. Maybe it's possible to reuse that? >> >> Thanks, >> Florian > > The problem is now that divdi3 is not provided by glibc anymore we can't > use the same trick since __divdi3 and __moddi3 will be provided by libgcc. > Another way to actually redefine .udiv is to either still keep using divdi3 > for sparc32 . > Any more impeding remark about this patch?
diff --git a/sysdeps/sparc/sparc32/Makefile b/sysdeps/sparc/sparc32/Makefile index da20589..6d2a196 100644 --- a/sysdeps/sparc/sparc32/Makefile +++ b/sysdeps/sparc/sparc32/Makefile @@ -47,3 +47,9 @@ $(divrem:%=$(sysdep_dir)/sparc/sparc32/%.S): $(sysdep_dir)/sparc/sparc32/divrem. mv -f $@-tmp $@ sysdep-realclean := $(sysdep-realclean) $(divrem:%=sysdeps/sparc/sparc32/%.S) + +# libgcc __divdi3 and __moddi3 use .udiv and since it is also exported by +# libc.so linker will create PLTs for the symbol. To avoid it we strong alias +# the exported libc one to __wrap_.udiv and use linker option --wrap to make any +# call to .udiv to call the wrapper symbol. +libc.so-gnulib += -Wl,--wrap=.udiv diff --git a/sysdeps/sparc/sparc32/sparcv8/udiv.S b/sysdeps/sparc/sparc32/sparcv8/udiv.S index d719543..e9cab4e 100644 --- a/sysdeps/sparc/sparc32/sparcv8/udiv.S +++ b/sysdeps/sparc/sparc32/sparcv8/udiv.S @@ -13,3 +13,4 @@ ENTRY(.udiv) udiv %o0, %o1, %o0 END(.udiv) +strong_alias (.udiv, __wrap_.udiv) diff --git a/sysdeps/sparc/sparc32/sparcv9/udiv.S b/sysdeps/sparc/sparc32/sparcv9/udiv.S index de79899..368f85e 100644 --- a/sysdeps/sparc/sparc32/sparcv9/udiv.S +++ b/sysdeps/sparc/sparc32/sparcv9/udiv.S @@ -15,3 +15,4 @@ ENTRY(.udiv) udiv %o0, %o1, %o0 END(.udiv) +strong_alias (.udiv, __wrap_.udiv) diff --git a/sysdeps/sparc/sparc32/udiv.S b/sysdeps/sparc/sparc32/udiv.S index 8dfff66..ade0afd 100644 --- a/sysdeps/sparc/sparc32/udiv.S +++ b/sysdeps/sparc/sparc32/udiv.S @@ -344,3 +344,4 @@ LOC(got_result): mov %o2, %o0 END(.udiv) +strong_alias (.udiv, __wrap_.udiv)