lkml.org 
[lkml]   [2015]   [Jul]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH 02/21] stackvalidate: Add C version of STACKVALIDATE_IGNORE_INSN
On Sat, Jul 18, 2015 at 09:16:58AM -0700, Linus Torvalds wrote:
> On Jul 17, 2015 09:57, "Josh Poimboeuf" <jpoimboe@redhat.com> wrote:
> >
> > +
> > +#define STACKVALIDATE_IGNORE_INSN \
> > + ".Ltemp" __stringify(__LINE__) ":;" \
>
> This is wrong. It won't work for people who do multiple of these on the
> same line (think macros etc).
>
> For temporary labels, you should just use numeric labels. Think Pascal
> style ones. Then use "b" or "f" after the number when referring to it to
> say "back" or "forward" reference.
>
> So the code for an endless loop with a true temporary label looks like:
>
> 1: code
> jmp 1b
>
> and a branch over would look like
>
> jne 7f
> .. code ...
> 7: ...
>
> and now you can have multiple of these truly temp labels without ever
> getting errors from having a label redefined.

Yeah, I think I'll change the C macro to do that.

However for asm macros you have to worry about collisions. For example:

.macro FOO
1: ...
.endm

1: ...
FOO
jmp 1b

It would jump to "1" in the macro instead of the "1" before the macro.

So for the asm version of the macro I ended up using Andy's idea of using "\@"
to get a unique identifier:

.macro STACKVALIDATE_IGNORE_INSN
.if CONFIG_STACK_VALIDATION
.Ltemp_\@:
.pushsection __stackvalidate_ignore_insn, "a"
_ASM_ALIGN
.long .Ltemp_\@ - .
.popsection
.endif
.endm


--
Josh


\
 
 \ /
  Last update: 2015-07-18 19:01    [W:0.171 / U:0.764 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site