4

I try to compile hello.c using gcc with -mnop-mcount option. But error occurs like below:

$ gcc -pg -mfentry -mnop-mcount -o hello hello.c
cc1: error: -mnop-mcount is not implemented for -fPIC

My gcc version is 7.3.0:

$ gcc --version
gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0
Copyright (C) 2017 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.

And my Ubuntu version is 18.04 LTS:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04 LTS
Release:    18.04
Codename:   bionic
1

1 Answer 1

1

gcc6 onwards generates fpic code by default because of the way it's compiled in ubuntu. To disable this behaviour use the fno-pic flag as follows:

gcc -pg -mfentry -mnop-mcount -fno-pic -o hello hello.c
1
  • You appear to be missing a -o before the output file name. Also I suspect -no-pie may be required here as well as -fno-pic. Jul 15, 2018 at 11:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .