Skip to contentSkip to conversation

asm: handle comments when creating header file

Makefile Applied Norbert Manthey 6 participants 9 messages Jan 10, 2018 – Feb 12, 2019

lore
Share & tools
lore
#0 lore raw

In the early steps of compilation, the asm header files are created, such as include/asm-$(TARGET_ARCH)/asm-offsets.h. These files depend on the assembly file arch/$(TARGET_ARCH)/asm-offsets.s, which is generated before. Depending on the used assembler, there might be comments in the assembly files.

This commit adds handling comments in the assembler during the creation of the asm header files.

---
 xen/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/Makefile +1 -1
index 044e7c8..841a9e5 100644
@@ -189,7 +189,7 @@ include/asm-$(TARGET_ARCH)/asm-offsets.h: arch/$(TARGET_ARCH)/asm-offsets.s
 	  echo "#ifndef __ASM_OFFSETS_H__"; \
 	  echo "#define __ASM_OFFSETS_H__"; \
 	  echo ""; \
-	  sed -rne "/==>/{s:.*==>(.*)<==.*:\1:; s: [\$$#]: :; p;}"; \
+	  sed -rne "/^[^#].*==>/{s:.*==>(.*)<==.*:\1:; s: [\$$#]: :; p;}"; \
 	  echo ""; \
 	  echo "#endif") <$< >$@
 
Signature · 7 lines
2.7.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 10.01.18 at 16:14, <[email protected]> wrote:

In the early steps of compilation, the asm header files are created, such as include/asm-$(TARGET_ARCH)/asm-offsets.h. These files depend on the assembly file arch/$(TARGET_ARCH)/asm-offsets.s, which is generated before. Depending on the used assembler, there might be comments in the assembly files.

This commit adds handling comments in the assembler during the creation of the asm header files.

I have a hard time seeing how ...

xen/Makefile include/asm-$(TARGET_ARCH)/asm-offsets.h: arch/$(TARGET_ARCH)/asm-offsets.s · line 192

Quoted 7 lines
xen/Makefile +0 -1
@@ -189,7 +189,7 @@ include/asm-$(TARGET_ARCH)/asm-offsets.h: arch/$(TARGET_ARCH)/asm-offsets.s
 	  echo "#ifndef __ASM_OFFSETS_H__"; \
 	  echo "#define __ASM_OFFSETS_H__"; \
 	  echo ""; \
-	  sed -rne "/==>/{s:.*==>(.*)<==.*:\1:; s: [\$$#]: :; p;}"; \

... this pattern could match any comment that we currently have. Would you mind clarifying what it is that is actually broken (and hence wants/needs fixing)?

Jan

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

#2 lore raw

Jan, All,

Quoted 14 lines · Jan Beulich
Quoted 10 lines
Quoted 2 lines
Quoted 2 lines · On 10.01.18 at 16:14, <[email protected]> wrote:

In the early steps of compilation, the asm header files are created, such as include/asm-$(TARGET_ARCH)/asm-offsets.h. These files depend on the assembly file arch/$(TARGET_ARCH)/asm-offsets.s, which is generated before. Depending on the used assembler, there might be comments in the assembly files.

This commit adds handling comments in the assembler during the creation of the asm header files.

I have a hard time seeing how ...

Quoted 12 lines

xen/Makefile include/asm-$(TARGET_ARCH)/asm-offsets.h: arch/$(TARGET_ARCH)/asm-offsets.s · line 192

Quoted 7 lines
xen/Makefile +0 -1
@@ -189,7 +189,7 @@ include/asm-$(TARGET_ARCH)/asm-offsets.h: arch/$(TARGET_ARCH)/asm-offsets.s
 	  echo "#ifndef __ASM_OFFSETS_H__"; \
 	  echo "#define __ASM_OFFSETS_H__"; \
 	  echo ""; \
-	  sed -rne "/==>/{s:.*==>(.*)<==.*:\1:; s: [\$$#]: :; p;}"; \

... this pattern could match any comment that we currently have. Would you mind clarifying what it is that is actually broken (and hence wants/needs fixing)?

Re-adding the new line:

+ sed -rne "/^[^#].*==>/{s:.*==>(.*)<==.*:\1:; s: [\$$#]: :; p;}"; \

The change "handles comments" by not printing those to the generated header file, where they would confuse the preprocessor (as "#" starts comments at the assembler level). It seems perfectly ok if this matches any existing comments as none such should get printed to the header file.

The problems showed up when using goto-gcc (a compiler for subsequent use of static analysis tooling), which embeds additional information in the comments.

Hope this helps,
Michael

Amazon Web Services UK Limited. Registered in England and Wales with registration number 08650665 and which has its registered office at 60 Holborn Viaduct, London EC1A 2FD, United Kingdom.

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

#3 lore raw
Quoted 34 lines
Quoted 1 line
Quoted 1 line · On 22.01.18 at 22:19, <[email protected]> wrote:

Jan, All,

Quoted 14 lines · Jan Beulich
Quoted 10 lines
Quoted 2 lines
Quoted 2 lines · On 10.01.18 at 16:14, <[email protected]> wrote:

In the early steps of compilation, the asm header files are created, such as include/asm-$(TARGET_ARCH)/asm-offsets.h. These files depend on the assembly file arch/$(TARGET_ARCH)/asm-offsets.s, which is generated before. Depending on the used assembler, there might be comments in the assembly files.

This commit adds handling comments in the assembler during the creation of the asm header files.

I have a hard time seeing how ...

Quoted 12 lines

xen/Makefile include/asm-$(TARGET_ARCH)/asm-offsets.h: arch/$(TARGET_ARCH)/asm-offsets.s · line 192

Quoted 7 lines
xen/Makefile +0 -1
@@ -189,7 +189,7 @@ include/asm-$(TARGET_ARCH)/asm-offsets.h: arch/$(TARGET_ARCH)/asm-offsets.s
 	  echo "#ifndef __ASM_OFFSETS_H__"; \
 	  echo "#define __ASM_OFFSETS_H__"; \
 	  echo ""; \
-	  sed -rne "/==>/{s:.*==>(.*)<==.*:\1:; s: [\$$#]: :; p;}"; \

... this pattern could match any comment that we currently have. Would you mind clarifying what it is that is actually broken (and hence wants/needs fixing)?

Re-adding the new line:

xen/Makefile +1 -0
+	  sed -rne "/^[^#].*==>/{s:.*==>(.*)<==.*:\1:; s: [\$$#]: :; p;}"; \
Quoted 8 lines

The change "handles comments" by not printing those to the generated header file, where they would confuse the preprocessor (as "#" starts comments at the assembler level). It seems perfectly ok if this matches any existing comments as none such should get printed to the header file.

The problems showed up when using goto-gcc (a compiler for subsequent use of static analysis tooling), which embeds additional information in the comments.

Please add some clarification along those lines to the description. I then also assume that you mean "used compiler" instead of "used assembler" in the description? Additionally, if you want to strip comments, please strip all of them, i.e. including such starting with # after some leading white space.

Furthermore, the character (or sequence of characters) starting a comment is target specific - this wants specifying by the per-arch Rules.mk, I think, so that it'll also work on ARM (where # has a different meaning). Along those lines, x86 allows // to start a (full line) comment as well.

Jan

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

#4 lore raw

PATCH v2 1/1 asm: handle comments when creating header file

From: Norbert Manthey <[email protected]>

In the early steps of compilation, the asm header files are created, such as include/asm-$(TARGET_ARCH)/asm-offsets.h. These files depend on the assembly file arch/$(TARGET_ARCH)/asm-offsets.s, which is generated before. Depending on the used toolchain, there might be comments in the assembly files. Especially the goto-gcc compiler of the bounded model checker CBMC adds comments that start with a '#' symbol at the beginning of the line.

This commit adds handling comments in assembler during the creation of the asm header files, especially ignoring lines that start with '#', which indicate comments for both ARM and x86 assembler. The used tool goto-as produces exactly comments of this kind.

---
 xen/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/Makefile +1 -1
@@ -191,7 +191,7 @@ include/asm-$(TARGET_ARCH)/asm-offsets.h: arch/$(TARGET_ARCH)/asm-offsets.s
 	  echo "#ifndef __ASM_OFFSETS_H__"; \
 	  echo "#define __ASM_OFFSETS_H__"; \
 	  echo ""; \
-	  sed -rne "/==>/{s:.*==>(.*)<==.*:\1:; s: [\$$#]: :; p;}"; \
+	  sed -rne "/^[^#].*==>/{s:.*==>(.*)<==.*:\1:; s: [\$$#]: :; p;}"; \
 	  echo ""; \
 	  echo "#endif") <$< >$@
 
Signature · 18 lines
2.7.4




Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrer: Christian Schlaeger, Ralf Herbrich
Ust-ID: DE 289 237 879
Eingetragen am Amtsgericht Charlottenburg HRB 149173 B



_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v2 1/1
#5 lore raw
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 06.02.19 at 15:09, <[email protected]> wrote:

From: Norbert Manthey <[email protected]>

In the early steps of compilation, the asm header files are created, such as include/asm-$(TARGET_ARCH)/asm-offsets.h. These files depend on the assembly file arch/$(TARGET_ARCH)/asm-offsets.s, which is generated before. Depending on the used toolchain, there might be comments in the assembly files. Especially the goto-gcc compiler of the bounded model checker CBMC adds comments that start with a '#' symbol at the beginning of the line.

Quoted 7 lines

This commit adds handling comments in assembler during the creation of the asm header files, especially ignoring lines that start with '#', which indicate comments for both ARM and x86 assembler. The used tool goto-as produces exactly comments of this kind.

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

#6 lore raw
Quoted 11 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 06.02.19 at 15:09, <[email protected]> wrote:

From: Norbert Manthey <[email protected]>

In the early steps of compilation, the asm header files are created, such as include/asm-$(TARGET_ARCH)/asm-offsets.h. These files depend on the assembly file arch/$(TARGET_ARCH)/asm-offsets.s, which is generated before. Depending on the used toolchain, there might be comments in the assembly files. Especially the goto-gcc compiler of the bounded model checker CBMC adds comments that start with a '#' symbol at the beginning of the line.

Quoted 9 lines
Quoted 7 lines

This commit adds handling comments in assembler during the creation of the asm header files, especially ignoring lines that start with '#', which indicate comments for both ARM and x86 assembler. The used tool goto-as produces exactly comments of this kind.

Jürgen, is there a chance to get this patch into the 4.12 release? It would be nice to be able to compile upstream Xen with the tool chain for the CBMC model checker (i.e. the goto-gcc compiler), as that tool chain allows to apply further reasoning. Thanks!

Best,
Norbert

Amazon Development Center Germany GmbH Krausenstr. 38
10117 Berlin
Geschaeftsfuehrer: Christian Schlaeger, Ralf Herbrich
Ust-ID: DE 289 237 879
Eingetragen am Amtsgericht Charlottenburg HRB 149173 B

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

#7 lore raw
Quoted 17 lines · Norbert Manthey
Quoted 16 lines · Jan Beulich
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 06.02.19 at 15:09, <[email protected]> wrote:

From: Norbert Manthey <[email protected]>

In the early steps of compilation, the asm header files are created, such as include/asm-$(TARGET_ARCH)/asm-offsets.h. These files depend on the assembly file arch/$(TARGET_ARCH)/asm-offsets.s, which is generated before. Depending on the used toolchain, there might be comments in the assembly files. Especially the goto-gcc compiler of the bounded model checker CBMC adds comments that start with a '#' symbol at the beginning of the line.

This commit adds handling comments in assembler during the creation of the asm header files, especially ignoring lines that start with '#', which indicate comments for both ARM and x86 assembler. The used tool goto-as produces exactly comments of this kind.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Jürgen, is there a chance to get this patch into the 4.12 release? It would be nice to be able to compile upstream Xen with the tool chain for the CBMC model checker (i.e. the goto-gcc compiler), as that tool chain allows to apply further reasoning. Thanks!

Juergen

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

Applied
#8 lore raw
Quoted 20 lines · Juergen Gross
Quoted 19 lines · Norbert Manthey
Quoted 18 lines · Jan Beulich
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 06.02.19 at 15:09, <[email protected]> wrote:

From: Norbert Manthey <[email protected]>

In the early steps of compilation, the asm header files are created, such as include/asm-$(TARGET_ARCH)/asm-offsets.h. These files depend on the assembly file arch/$(TARGET_ARCH)/asm-offsets.s, which is generated before. Depending on the used toolchain, there might be comments in the assembly files. Especially the goto-gcc compiler of the bounded model checker CBMC adds comments that start with a '#' symbol at the beginning of the line.

This commit adds handling comments in assembler during the creation of the asm header files, especially ignoring lines that start with '#', which indicate comments for both ARM and x86 assembler. The used tool goto-as produces exactly comments of this kind.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Jürgen, is there a chance to get this patch into the 4.12 release? It would be nice to be able to compile upstream Xen with the tool chain for the CBMC model checker (i.e. the goto-gcc compiler), as that tool chain allows to apply further reasoning. Thanks!

Applied.

Wei.

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