All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86emul/test: don't use *_len symbols
@ 2017-01-24 15:02 Jan Beulich
  2017-01-24 15:09 ` Wei Liu
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2017-01-24 15:02 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper, Wei Liu

[-- Attachment #1: Type: text/plain, Size: 1971 bytes --]

... as they don't work as intended with -fPIC.

I did prefer them over *_end ones at the time because older gcc would
cause .L* symbols to be public, due to issuing .globl for all
referenced externals. And labels at the end of instructions collide
with the ones at the start of the next instruction, making disassembly
harder to grok. Luckily recent gcc no longer issues those .globl
directives, and hence .L* labels, staying local by default, no longer
get in the way.

Reported-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/tools/tests/x86_emulator/test_x86_emulator.c
+++ b/tools/tests/x86_emulator/test_x86_emulator.c
@@ -885,17 +885,16 @@ int main(int argc, char **argv)
     }
     printf("okay\n");
 
-#define decl_insn(which) extern const unsigned char which[], which##_len[]
+#define decl_insn(which) extern const unsigned char which[], \
+                         which##_end[] asm ( ".L" #which "_end" )
 #define put_insn(which, insn) ".pushsection .test, \"ax\", @progbits\n" \
                               #which ": " insn "\n"                     \
-                              ".equ " #which "_len, .-" #which "\n"     \
+                              ".L" #which "_end:\n"                     \
                               ".popsection"
 #define set_insn(which) (regs.eip = (unsigned long)(which))
 #define valid_eip(which) (regs.eip >= (unsigned long)(which) && \
-                          regs.eip < (unsigned long)(which) + \
-                                      (unsigned long)which##_len)
-#define check_eip(which) (regs.eip == (unsigned long)(which) + \
-                                      (unsigned long)which##_len)
+                          regs.eip < (unsigned long)which##_end)
+#define check_eip(which) (regs.eip == (unsigned long)which##_end)
 
     printf("%-40s", "Testing andn (%edx),%ecx,%ebx...");
     if ( stack_exec && cpu_has_bmi1 )




[-- Attachment #2: x86emul-test-no-len.patch --]
[-- Type: text/plain, Size: 2006 bytes --]

x86emul/test: don't use *_len symbols

... as they don't work as intended with -fPIC.

I did prefer them over *_end ones at the time because older gcc would
cause .L* symbols to be public, due to issuing .globl for all
referenced externals. And labels at the end of instructions collide
with the ones at the start of the next instruction, making disassembly
harder to grok. Luckily recent gcc no longer issues those .globl
directives, and hence .L* labels, staying local by default, no longer
get in the way.

Reported-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/tools/tests/x86_emulator/test_x86_emulator.c
+++ b/tools/tests/x86_emulator/test_x86_emulator.c
@@ -885,17 +885,16 @@ int main(int argc, char **argv)
     }
     printf("okay\n");
 
-#define decl_insn(which) extern const unsigned char which[], which##_len[]
+#define decl_insn(which) extern const unsigned char which[], \
+                         which##_end[] asm ( ".L" #which "_end" )
 #define put_insn(which, insn) ".pushsection .test, \"ax\", @progbits\n" \
                               #which ": " insn "\n"                     \
-                              ".equ " #which "_len, .-" #which "\n"     \
+                              ".L" #which "_end:\n"                     \
                               ".popsection"
 #define set_insn(which) (regs.eip = (unsigned long)(which))
 #define valid_eip(which) (regs.eip >= (unsigned long)(which) && \
-                          regs.eip < (unsigned long)(which) + \
-                                      (unsigned long)which##_len)
-#define check_eip(which) (regs.eip == (unsigned long)(which) + \
-                                      (unsigned long)which##_len)
+                          regs.eip < (unsigned long)which##_end)
+#define check_eip(which) (regs.eip == (unsigned long)which##_end)
 
     printf("%-40s", "Testing andn (%edx),%ecx,%ebx...");
     if ( stack_exec && cpu_has_bmi1 )

[-- Attachment #3: Type: text/plain, Size: 127 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH] x86emul/test: don't use *_len symbols
  2017-01-24 15:02 [PATCH] x86emul/test: don't use *_len symbols Jan Beulich
@ 2017-01-24 15:09 ` Wei Liu
  0 siblings, 0 replies; 2+ messages in thread
From: Wei Liu @ 2017-01-24 15:09 UTC (permalink / raw)
  To: Jan Beulich; +Cc: xen-devel, Wei Liu, Andrew Cooper

On Tue, Jan 24, 2017 at 08:02:23AM -0700, Jan Beulich wrote:
> ... as they don't work as intended with -fPIC.
> 
> I did prefer them over *_end ones at the time because older gcc would
> cause .L* symbols to be public, due to issuing .globl for all
> referenced externals. And labels at the end of instructions collide
> with the ones at the start of the next instruction, making disassembly
> harder to grok. Luckily recent gcc no longer issues those .globl
> directives, and hence .L* labels, staying local by default, no longer
> get in the way.
> 
> Reported-by: Wei Liu <wei.liu2@citrix.com>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 

Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Tested-by: Wei Liu <wei.liu2@citrix.com>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

end of thread, other threads:[~2017-01-24 15:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-24 15:02 [PATCH] x86emul/test: don't use *_len symbols Jan Beulich
2017-01-24 15:09 ` Wei Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.