title: Why does register_tm_clones and deregister_tm_clones reference an address past the .bss section? Where is this memory allocated?
body: <p><code>register_tm_clones</code> and <code>deregister_tm_clones</code> are referencing memory addresses past the end of my RW sections. How is this memory tracked?</p>
  
  <p><strong>Example:</strong> In the example below <code>deregister_tm_clones</code> references memory address <code>0x601077</code>, but the last RW section we allocated, <code>.bss</code> starts at <code>0x601069</code> and has size <code>0x7</code>, adding we get <code>0x601070</code>. So the reference is clearly past whats been allocated for the <code>.bss</code> section and should be in our heap space, but who's managing it. </p>
  
  <pre><code>objdump -d main
  ...
  0000000000400540 &amp;lt;deregister_tm_clones&amp;gt;:
    400540:       b8 77 10 60 00          mov    $0x601077,%eax
    400545:       55                      push   %rbp
    400546:       48 2d 70 10 60 00       sub    $0x601070,%rax
    40054c:       48 83 f8 0e             cmp    $0xe,%rax
  ...
  
  readelf -S main
  ...
  [25] .data             PROGBITS         0000000000601040  00001040
     0000000000000029  0000000000000000  WA       0     0     16
  [26] .bss              NOBITS           0000000000601069  00001069
     0000000000000007  0000000000000000  WA       0     0     1
  [27] .comment          PROGBITS         0000000000000000  00001069
     0000000000000058  0000000000000001  MS       0     0     1
  [28] .shstrtab         STRTAB           0000000000000000  000019f2
     000000000000010c  0000000000000000           0     0     1
  [29] .symtab           SYMTAB           0000000000000000  000010c8
     00000000000006c0  0000000000000018          30    47     8
  [30] .strtab           STRTAB           0000000000000000  00001788
     000000000000026a  0000000000000000           0     0     1
  </code></pre>
  
  <p>Note that the references start exactly at the end of the <code>.bss</code> section. When I examine the memory allocated using gdb, I see that there is plenty of space, so it works fine, but I don't see how this memory is managed.</p>
  
  <pre><code>Start Addr         End Addr          Size        Offset objfile
  0x400000           0x401000          0x1000      0x0 /home/nobody/main
  0x600000           0x601000          0x1000      0x0 /home/nobody/main
  0x601000           0x602000          0x1000      0x1000 /home/nobody/main
  0x7ffff7a17000     0x7ffff7bd0000    0x1b9000    0x0 /usr/lib64/libc-2.23.so
  </code></pre>
  
  <p>I can find no other reference to it in any other sections. There is also no space reserved for it in by the segment loaded for .bss:</p>
  
  <pre><code>LOAD         0x0000000000000e10 0x0000000000600e10 0x0000000000600e10
               0x0000000000000259 0x0000000000000260  RW     200000
  </code></pre>
  
  <p>Can anyone clarify these functions? Where is the source? I've read all the references on transactional memory, but they cover programming not implementation. I can not find a compiler option to remove this code, except of course <code>-nostdlibs</code> which leaves you with nothing. </p>
  
  <p>Are these part of malloc perhaps? Still for code that's not using malloc, threading, or STM, I'm not sure I agree these should be linked into my code.</p>
  
  <p>See also <a href="https://stackoverflow.com/questions/34966097/what-functions-does-gcc-add-to-the-linux-elf">What functions does gcc add to the linux ELF?</a></p>
  
  <p><b>More details:</b></p>
  
  <pre><code>$ make main
  cc -c -o main.o main.c
  cc -o main main.o
  
  $ which cc
  /usr/bin/cc
  
  $ cc --version
      cc (GCC) 6.2.1 20160916 (Red Hat 6.2.1-2)
  Copyright (C) 2016 Free Software Foundation, Inc.
  This is free software; see the source for copying conditions.  There is NO
  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  
  $ cc --verbose
  Using built-in specs.
  COLLECT_GCC=cc
  COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/6.2.1/lto-wrapper
  Target: x86_64-redhat-linux
  Configured with: ../configure --enable-bootstrap
   --enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto
   --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info
   --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
   --enable-threads=posix --enable-checking=release --enable-multilib
   --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
   --enable-gnu-unique-object --enable-linker-build-id
   --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array
   --disable-libgcj --with-isl --enable-libmpx --enable-gnu-indirect-function
   --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
  Thread model: posix
  gcc version 6.2.1 20160916 (Red Hat 6.2.1-2) (GCC)
  </code></pre>