<div dir="ltr"><div>Pushed to the master branch, Thanks</div><div dir="ltr"><br></div><div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Oct 18, 2022 at 6:00 PM chen <<a href="mailto:chenm003@163.com">chenm003@163.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="line-height:1.7;color:rgb(0,0,0);font-size:14px;font-family:Arial"><div style="margin:0px">Hi Song,</div><div style="margin:0px"><br></div><div style="margin:0px"><div style="margin:0px">This is a long time history bug. the '-DPIC' just add to compile option when Nasm is enabled, the bug can simple fix with below patch (NO TEST since I haven't ARM environment).</div><div style="margin:0px">After patch, the user may acivate these compile option with <b>ENABLE_PIC=ON</b></div><div style="margin:0px"><br></div><div style="margin:0px">Could the x265 team please help verify patch?</div><div style="margin:0px"><br></div></div><div style="margin:0px"><div style="margin:0px">Regards,</div><div style="margin:0px">Min Chen</div><div><br></div></div><div style="margin:0px"><div style="margin:0px"><i>diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt</i></div><div style="margin:0px">index 13e4750de..80f8e59a9 100755</div><div style="margin:0px">--- a/source/CMakeLists.txt</div><div style="margin:0px">+++ b/source/CMakeLists.txt</div><div style="margin:0px">@@ -266,6 +266,9 @@ if(GCC)</div><div style="margin:0px"> add_definitions(-DHAVE_NEON)</div><div style="margin:0px"> endif()</div><div style="margin:0px"> endif()</div><div style="margin:0px">+ if(ENABLE_PIC)</div><div style="margin:0px">+ list(APPEND ARM_ARGS -DPIC)</div><div style="margin:0px">+ endif()</div><div style="margin:0px"> add_definitions(${ARM_ARGS})</div><div style="margin:0px"> if(FPROFILE_GENERATE)</div><div style="margin:0px"> if(INTEL_CXX)</div><div style="margin:0px"><br></div></div><div style="margin:0px"> 2022-10-18 14:37:10,"Fangrui Song" <<a href="mailto:maskray@google.com" target="_blank">maskray@google.com</a>> </div><blockquote id="m_-4267246632095818986isReplyContent" style="padding-left:1ex;margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204)"><div dir="ltr"><div dir="ltr">On Thu, Oct 6, 2022 at 1:39 AM chen <<a href="mailto:chenm003@163.com" target="_blank">chenm003@163.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="line-height:1.7;color:rgb(0,0,0);font-size:14px;font-family:Arial"><p style="margin:0px">Hi Song,</p><p style="margin:0px"><br></p><p style="margin:0px">I means the current tree support these adrp+add mode with compile option -DPIC, so we need not patch the code.</p><p style="margin:0px"><br></p><div style="margin:0px">Regards,</div><div style="margin:0px">Min Chen</div></div></blockquote><div><br></div><div>Hi Min, IIUC -DPIC is only defined for x86-64 (source/cmake/CMakeASM_NASMInformation.cmake).</div><div>AArch64 does not get -DPIC.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="line-height:1.7;color:rgb(0,0,0);font-size:14px;font-family:Arial"><p>2022-10-06 06:42:33,"Fangrui Song" <<a href="mailto:maskray@google.com" target="_blank">maskray@google.com</a>> </p><blockquote id="m_-4267246632095818986m_7785447474155776703isReplyContent" style="padding-left:1ex;margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204)"><div dir="ltr"><div dir="ltr">Hi Min, sorry but I just saw your question. I do not understand the request.</div><div class="gmail_quote"><div>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.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="line-height:1.7;color:rgb(0,0,0);font-size:14px;font-family:Arial"><pre><div>At 2022-09-24 15:21:35, "Fangrui Song" <<a href="mailto:maskray@google.com" target="_blank">maskray@google.com</a>> wrote:</div>>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 <a href="https://maskray.me/blog/2020-12-19-lld-and-gnu-linker-incompatibilities#:~:text=Text%20relocations" target="_blank">https://maskray.me/blog/2020-12-19-lld-and-gnu-linker-incompatibilities#:~:text=Text%20relocations</a>)
>>
>>```
>>% : && /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" <<a href="mailto:maskray@google.com" target="_blank">maskray@google.com</a>> 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
>>>>><a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a>
>>>>><a href="https://mailman.videolan.org/listinfo/x265-devel" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a>
>>>
>>>>_______________________________________________
>>>>x265-devel mailing list
>>>><a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a>
>>>><a href="https://mailman.videolan.org/listinfo/x265-devel" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a>
>>>
>_______________________________________________
>x265-devel mailing list
><a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a>
><a href="https://mailman.videolan.org/listinfo/x265-devel" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a>
</pre></div>_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr">宋方睿</div></div></div>
</blockquote></div>_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr">宋方睿</div></div></div>
</blockquote></div>_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div></div>