[x265] PING [PATCH] aarch64: replace ldr pseudo-instruction with adrp+add

Fangrui Song maskray at google.com
Wed Oct 5 22:42:33 UTC 2022


On Sat, Sep 24, 2022 at 6:53 AM chen <chenm003 at 163.com> wrote:

> Hi Song,
>
> Sorry for delay.
> The new patches just clean up some code that assume already declare
> defined(PIC) on aarch64, so I still think we need not do like this, declare
> -DPIC on cmdline is more general.
> On previous error message of sad-a.S, the compile option is '-fPIC', I
> guess we need '-fPIC -DPIC'
>
> Regards, Min Chen
>

Hi Min, sorry but I just saw your question. I do not understand the request.
adrp+add is just strictly superior to ldr (which uses a constant pool and
does not decrease code size) and avoids text relocations (which are
prohibited in many systems).  `ldr             \rd, =\val+\offset` should
just be removed. adrp+add also works on Mach-O systems as well.


> At 2022-09-24 15:21:35, "Fangrui Song" <maskray at google.com> wrote:
> >Ping.  The breaks lld build and some binutils configurating defaulting
> >to disallow text relocations.
> >
> >On 2022-08-29, Fangrui Song wrote:
> >>On 2022-08-29, Fangrui Song wrote:
> >>>On 2022-08-30, chen wrote:
> >>>>Hi Song,
> >>>>
> >>>>
> >>>>Thank you for your patch.
> >>>>
> >>>>
> >>>>However, syntax of ':lo12:' depends on compiler, so more general LDR is better in here.
> >>>>
> >>>>
> >>>>Regards,
> >>>>Min Chen
> >>>
> >>>:lo12: is standard aarch64 assembly syntax.
> >>>Which aarch64 compiler supported by x265 does not support :lo12:?
> >>
> >>Note that LDR has another problem that it produced an absolute relocation R_AARCH64_ABS64. It will trigger an error
> >>when text relocations are disabled (default in ld.lld. See https://maskray.me/blog/2020-12-19-lld-and-gnu-linker-incompatibilities#:~:text=Text%20relocations)
> >>
> >>```
> >>% : && /usr/bin/c++ -fPIC -O3 -DNDEBUG  -Wl,-Bsymbolic,-znoexecstack -shared ...
> >>ld: error: relocation R_AARCH64_ABS64 cannot be used against local
> >>symbol; recompile with -fPIC
> >>>>>defined in sad-a.S.o
> >>>>>>>> referenced by sad-a.S.o:(.text+0x9B00)
> >>```
> >>
> >>adrp+add work fine.
> >>
> >>(I am a maintainer of lld/ELF.)
> >>
> >>>>At 2022-08-30 02:33:37, "Fangrui Song" <maskray at google.com> wrote:
> >>>>>The ldr pseudo-instruction uses a literal pool, which is less efficient
> >>>>>and does not decrease the code size.
> >>>>>---
> >>>>>source/common/aarch64/asm.S | 4 +---
> >>>>>1 file changed, 1 insertion(+), 3 deletions(-)
> >>>>>
> >>>>>diff --git a/source/common/aarch64/asm.S b/source/common/aarch64/asm.S
> >>>>>index 399c37cf2..2506f50aa 100644
> >>>>>--- a/source/common/aarch64/asm.S
> >>>>>+++ b/source/common/aarch64/asm.S
> >>>>>@@ -130,11 +130,9 @@ ELF     .size   \name, . - \name
> >>>>>       adrp            \rd, \val+(\offset)
> >>>>>       add             \rd, \rd, :lo12:\val+(\offset)
> >>>>> .endif
> >>>>>-#elif defined(PIC)
> >>>>>+#else
> >>>>>       adrp            \rd, \val+(\offset)
> >>>>>       add             \rd, \rd, :lo12:\val+(\offset)
> >>>>>-#else
> >>>>>-        ldr             \rd, =\val+\offset
> >>>>>#endif
> >>>>>.endm
> >>>>>
> >>>>>--
> >>>>>2.37.2.672.g94769d06f0-goog
> >>>>>
> >>>>>_______________________________________________
> >>>>>x265-devel mailing list
> >>>>>x265-devel at videolan.org
> >>>>>https://mailman.videolan.org/listinfo/x265-devel
> >>>
> >>>>_______________________________________________
> >>>>x265-devel mailing list
> >>>>x265-devel at videolan.org
> >>>>https://mailman.videolan.org/listinfo/x265-devel
> >>>
> >_______________________________________________
> >x265-devel mailing list
> >x265-devel at videolan.org
> >https://mailman.videolan.org/listinfo/x265-devel
>
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>


-- 
宋方睿
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20221005/c1010ad3/attachment.html>


More information about the x265-devel mailing list