<div dir="ltr"><div>OK, I didn't know there is a patch in mail list. BTW, it seems there is no meaningful difference</div><div>with the generated code: when it's trying to align to 32 bytes border, since the actual code size</div><div>is between 32 and 64, actually the entry size is 64. So in this case, balign to 32 or 64 has same result</div><div><br></div><div>I heard that mesa will change to use libglvnd, if that will happen soon, then we don't worry about code here</div><div>any more.</div><div><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 27, 2019 at 5:57 AM Jonathan Gray <<a href="mailto:jsg@jsg.id.au">jsg@jsg.id.au</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">On Sun, Nov 11, 2018 at 03:47:35PM +1100, Jonathan Gray wrote:<br>
> Make similiar changes to libglvnd to avoid a text relocation in<br>
> x86 tsd stubs fixing the build with lld.<br>
> <br>
> v2:<br>
> - store the address of the GOT in ebx required before calling PLT stub<br>
> - change .balign values to match X86_ENTRY_SIZE<br>
<br>
When a different version of this patch was committed/pushed in<br>
45206d7673adb1484cbdb3eadaf82e0849c9cdcf<br>
(with author rewritten to imply I wrote the commit message)<br>
it did not include the .balign changes to match the entry size change.<br>
<br>
Was this purposefully skipped or overlooked as the bugzilla patch was<br>
used?<br>
<br>
The diff to what was committed and this patch is<br>
<br>
diff --git a/src/mapi/entry_x86_tsd.h b/src/mapi/entry_x86_tsd.h<br>
index bd8db7b19f9..1dec3ed86c4 100644<br>
--- a/src/mapi/entry_x86_tsd.h<br>
+++ b/src/mapi/entry_x86_tsd.h<br>
@@ -34,18 +34,18 @@<br>
#define X86_ENTRY_SIZE 64<br>
<br>
__asm__(".text\n"<br>
- ".balign 32\n"<br>
+ ".balign " U_STRINGIFY(X86_ENTRY_SIZE) "\n"<br>
"x86_entry_start:");<br>
<br>
#define STUB_ASM_ENTRY(func) \<br>
".globl " func "\n" \<br>
".type " func ", @function\n" \<br>
- ".balign 32\n" \<br>
+ ".balign " U_STRINGIFY(X86_ENTRY_SIZE) "\n" \<br>
func ":"<br>
<br>
#define STUB_ASM_CODE(slot) \<br>
"push %ebx\n\t" \<br>
- "call 1f\n\t" \<br>
+ "call 1f\n" \<br>
"1:\n\t" \<br>
"popl %ebx\n\t" \<br>
"addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx\n\t" \<br>
@@ -53,7 +53,7 @@ __asm__(".text\n"<br>
"mov (%eax), %eax\n\t" \<br>
"testl %eax, %eax\n\t" \<br>
"jne 1f\n\t" \<br>
- "call " ENTRY_CURRENT_TABLE_GET "@PLT\n\t" \<br>
+ "call " ENTRY_CURRENT_TABLE_GET "@PLT\n" \<br>
"1:\n\t" \<br>
"pop %ebx\n\t" \<br>
"jmp *(4 * " slot ")(%eax)"<br>
@@ -63,7 +63,7 @@ __asm__(".text\n"<br>
<br>
#ifndef MAPI_MODE_BRIDGE<br>
<br>
-__asm__(".balign 32\n"<br>
+__asm__(".balign " U_STRINGIFY(X86_ENTRY_SIZE) "\n"<br>
"x86_entry_end:");<br>
<br>
#include <string.h><br>
<br>
> <br>
> Signed-off-by: Jonathan Gray <<a href="mailto:jsg@jsg.id.au" target="_blank">jsg@jsg.id.au</a>><br>
> Cc: <a href="mailto:mesa-stable@lists.freedesktop.org" target="_blank">mesa-stable@lists.freedesktop.org</a><br>
> Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=108541" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=108541</a><br>
> ---<br>
> src/mapi/entry_x86_tsd.h | 22 ++++++++++++++--------<br>
> 1 file changed, 14 insertions(+), 8 deletions(-)<br>
> <br>
> diff --git a/src/mapi/entry_x86_tsd.h b/src/mapi/entry_x86_tsd.h<br>
> index 0c28c8ff068..1dec3ed86c4 100644<br>
> --- a/src/mapi/entry_x86_tsd.h<br>
> +++ b/src/mapi/entry_x86_tsd.h<br>
> @@ -31,25 +31,31 @@<br>
> #define HIDDEN<br>
> #endif<br>
> <br>
> -#define X86_ENTRY_SIZE 32<br>
> +#define X86_ENTRY_SIZE 64<br>
> <br>
> __asm__(".text\n"<br>
> - ".balign 32\n"<br>
> + ".balign " U_STRINGIFY(X86_ENTRY_SIZE) "\n"<br>
> "x86_entry_start:");<br>
> <br>
> #define STUB_ASM_ENTRY(func) \<br>
> ".globl " func "\n" \<br>
> ".type " func ", @function\n" \<br>
> - ".balign 32\n" \<br>
> + ".balign " U_STRINGIFY(X86_ENTRY_SIZE) "\n" \<br>
> func ":"<br>
> <br>
> #define STUB_ASM_CODE(slot) \<br>
> - "movl " ENTRY_CURRENT_TABLE ", %eax\n\t" \<br>
> + "push %ebx\n\t" \<br>
> + "call 1f\n" \<br>
> + "1:\n\t" \<br>
> + "popl %ebx\n\t" \<br>
> + "addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx\n\t" \<br>
> + "movl " ENTRY_CURRENT_TABLE "@GOT(%ebx), %eax\n\t" \<br>
> + "mov (%eax), %eax\n\t" \<br>
> "testl %eax, %eax\n\t" \<br>
> - "je 1f\n\t" \<br>
> - "jmp *(4 * " slot ")(%eax)\n" \<br>
> + "jne 1f\n\t" \<br>
> + "call " ENTRY_CURRENT_TABLE_GET "@PLT\n" \<br>
> "1:\n\t" \<br>
> - "call " ENTRY_CURRENT_TABLE_GET "\n\t" \<br>
> + "pop %ebx\n\t" \<br>
> "jmp *(4 * " slot ")(%eax)"<br>
> <br>
> #define MAPI_TMP_STUB_ASM_GCC<br>
> @@ -57,7 +63,7 @@ __asm__(".text\n"<br>
> <br>
> #ifndef MAPI_MODE_BRIDGE<br>
> <br>
> -__asm__(".balign 32\n"<br>
> +__asm__(".balign " U_STRINGIFY(X86_ENTRY_SIZE) "\n"<br>
> "x86_entry_end:");<br>
> <br>
> #include <string.h><br>
> -- <br>
> 2.19.1<br>
> <br>
> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div></div>