1

I'm reading the glibc source code, trying to debug a deadlock.

In my stack trace, I see:

#0  0x00007ff58b449eec in __lll_lock_wait_private () from /lib64/libc.so.6
#1  0x00007ff58b3bda31 in _L_lock_423 () from /lib64/libc.so.6
#2  0x00007ff58b3bbca8 in __GI__IO_link_in () from /lib64/libc.so.6
#3  0x00007ff58b3bab92 in __GI__IO_file_init () from /lib64/libc.so.6

But looking through the code, the only reference to _L_lock_ is in the macro lll_lock in lowlevellock.h.

There I see a string inside an inline assembly statement:

".type _L_lock_%=, @function\n"

This somehow becomes the function _L_lock_423 in my call stack. Where does the 423 appear from? What is the %= notation? what does %= mean in assembly?

Shalom Craimer
  • 20,659
  • 8
  • 70
  • 106
  • 3
    https://locklessinc.com/articles/gcc_asm/ GCC inline ASM. The '%=' operand prints a unique numeric identifier within the compilation region. This is helpful for constructing a unique symbol from within an inline asm. – Alex F Mar 21 '18 at 13:33
  • This is the reverse question of [Labels in GCC inline assembly](https://stackoverflow.com/questions/3898435/labels-in-gcc-inline-assembly), where `%=` is one of the answers, and the question is the problem that `%=` solves. Not exactly a duplicate, I guess. – Peter Cordes Mar 22 '18 at 03:02

1 Answers1

3

As described in the gcc docs:

‘%=’ - Outputs a number that is unique to each instance of the asm statement in the entire compilation. This option is useful when creating local labels and referring to them multiple times in a single template that generates multiple assembler instructions.

David Wohlferd
  • 7,110
  • 2
  • 29
  • 56