Recent

Author Topic: Enable -gh flag cause linker to fail heaptrc.o  (Read 300 times)

zamronypj

  • New Member
  • *
  • Posts: 41
    • Fano Framework, Free Pascal web application framework
Enable -gh flag cause linker to fail heaptrc.o
« on: June 15, 2019, 06:11:04 am »
I am trying to compile a program with Free Pascal, with -gh flag to turn on heaptrc to find out memory leak and get error message

/usr/bin/ld: /usr/local/lib/fpc/3.0.4/units/x86_64-linux/rtl/heaptrc.o: undefined reference to symbol '_end'
//usr/lib/x86_64-linux-gnu/librtmp.so.1: error adding symbols: DSO missing from command line

If I turn off -gh flag, my program successfully built.

Previously -gh flag was working fine. It seems it happens after I run Free Pascal cross compiling or after install libcurl4-gnutls-dev. I don't know and can't remember.

Why is error message triggered?

Original post
https://stackoverflow.com/questions/54806974/free-pascal-compiler-failed-to-link-with-error-heaptrc-o-undefined-reference-t
Fano Framework, Free Pascal web application framework https://fanoframework.github.io
Personal Projects https://v3.juhara.com
Github https://github.com/zamronypj

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 670
Re: Enable -gh flag cause linker to fail heaptrc.o
« Reply #1 on: June 15, 2019, 11:59:21 am »
It seems that linking libcurl somehow hides the "_end" symbol: https://stackoverflow.com/questions/13328144/end-symbol-disappears-when-linking-to-libcurl

-gh needs this symbol to know where the initialised data section ends. I'm not sure there's anything FPC can do to fix this, since it apparently also happens with gcc (and I'm not aware of another easy way to detect that address).