Skip to contentSkip to conversation

tests/x86emul: Annotate test blobs as executable code

PATCH Jan Beulich 2 participants 3 messages Jul 3, 2019 – Aug 5, 2019

lore
Share & tools
lore
#0 lore raw

tools/tests/x86_emulator/Makefile $(addsuffix .h,$(TESTCASES)): %.h: %.c testcase.mk Makefile · line 152

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 24.05.19 at 17:15, <[email protected]> wrote:
tools/tests/x86_emulator/Makefile +1 -1
@@ -149,7 +149,7 @@ $(addsuffix .h,$(TESTCASES)): %.h: %.c testcase.mk Makefile
 		(echo 'static const unsigned int __attribute__((section(".test, \"ax\", @progbits #")))' \
 		      "$${prefix}_$(arch)$${flavor}[] = {"; \
 		 od -v -t x $*.bin | sed -e 's/^[0-9]* /0x/' -e 's/ /, 0x/g' -e 's/$$/,/'; \
-		 echo "};") >>[email protected]; \
+		 echo "}; asm(\".type $${prefix}_$(arch)$${flavor}, STT_FUNC;\");") >>[email protected]; \

While I think we've sufficiently agreed on future gas behavior that I'd consider this change fine to make as long as you add an intermediate step going through STT_NOTYPE, I'd like to note that your mileage from this will only be about 50%: While the 64-bit blobs will disassemble fine, I'm afraid the 32-bit ones will be somewhat garbled. Sadly there's no annotation or alike (like Arm's mapping symbols) that one could use to make disassemblers switch bitness for separate blocks of code.

Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#1 lore raw
Quoted 17 lines · Jan Beulich

tools/tests/x86_emulator/Makefile $(addsuffix .h,$(TESTCASES)): %.h: %.c testcase.mk Makefile · line 152

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 24.05.19 at 17:15, <[email protected]> wrote:
tools/tests/x86_emulator/Makefile +1 -1
@@ -149,7 +149,7 @@ $(addsuffix .h,$(TESTCASES)): %.h: %.c testcase.mk Makefile
 		(echo 'static const unsigned int __attribute__((section(".test, \"ax\", @progbits #")))' \
 		      "$${prefix}_$(arch)$${flavor}[] = {"; \
 		 od -v -t x $*.bin | sed -e 's/^[0-9]* /0x/' -e 's/ /, 0x/g' -e 's/$$/,/'; \
-		 echo "};") >>[email protected]; \
+		 echo "}; asm(\".type $${prefix}_$(arch)$${flavor}, STT_FUNC;\");") >>[email protected]; \

While I think we've sufficiently agreed on future gas behavior that I'd consider this change fine to make as long as you add an intermediate step going through STT_NOTYPE, I'd like to note that your mileage from this will only be about 50%: While the 64-bit blobs will disassemble fine, I'm afraid the 32-bit ones will be somewhat garbled. Sadly there's no annotation or alike (like Arm's mapping symbols) that one could use to make disassemblers switch bitness for separate blocks of code.

Thats fine.

Disassembling twice, once with -mi386 works well, as the symbol names still get emitted sensibly.  I even use -m i8086 for bits of Xen's trampoline.

Its rare to need to look at a different disassembly, but its very easy to do so if you need to.

Can I take this reply as an ack for using the STT_NOTYPE intermediate step?

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 21 lines · Andrew Cooper
Quoted 17 lines · Jan Beulich

tools/tests/x86_emulator/Makefile $(addsuffix .h,$(TESTCASES)): %.h: %.c testcase.mk Makefile · line 152

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 24.05.19 at 17:15, <[email protected]> wrote:
tools/tests/x86_emulator/Makefile +1 -1
@@ -149,7 +149,7 @@ $(addsuffix .h,$(TESTCASES)): %.h: %.c testcase.mk Makefile
  		(echo 'static const unsigned int __attribute__((section(".test, \"ax\", @progbits #")))' \
  		      "$${prefix}_$(arch)$${flavor}[] = {"; \
  		 od -v -t x $*.bin | sed -e 's/^[0-9]* /0x/' -e 's/ /, 0x/g' -e 's/$$/,/'; \
-		 echo "};") >>[email protected]; \
+		 echo "}; asm(\".type $${prefix}_$(arch)$${flavor}, STT_FUNC;\");") >>[email protected]; \

While I think we've sufficiently agreed on future gas behavior that I'd consider this change fine to make as long as you add an intermediate step going through STT_NOTYPE, I'd like to note that your mileage from this will only be about 50%: While the 64-bit blobs will disassemble fine, I'm afraid the 32-bit ones will be somewhat garbled. Sadly there's no annotation or alike (like Arm's mapping symbols) that one could use to make disassemblers switch bitness for separate blocks of code.

Thats fine.

Quoted 8 lines

Disassembling twice, once with -mi386 works well, as the symbol names still get emitted sensibly.  I even use -m i8086 for bits of Xen's trampoline.

Its rare to need to look at a different disassembly, but its very easy to do so if you need to.

Can I take this reply as an ack for using the STT_NOTYPE intermediate step?

Yes - sorry for not being explicit in this regard.

Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel