]> git.ipfire.org Git - thirdparty/libvirt.git/commit
Prevent more compiler optimization of mockable functions
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 5 Jul 2017 10:46:28 +0000 (11:46 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 11 Jul 2017 12:57:12 +0000 (13:57 +0100)
commite4b980c853d2114b25fa805a84ea288384416221
tree87d4b10aa7560a7793b8004246d818e30d68f526
parent1dbbcb629a9edbc1ab1b0fb5bbdbe1878e9e15b8
Prevent more compiler optimization of mockable functions

Currently all mockable functions are annotated with the 'noinline'
attribute. This is insufficient to guarantee that a function can
be reliably mocked with an LD_PRELOAD. The C language spec allows
the compiler to assume there is only a single implementation of
each function. It can thus do things like propagating constant
return values into the caller at compile time, or creating
multiple specialized copies of the function body each optimized
for a different caller. To prevent these optimizations we must
also set the 'noclone' and 'weak' attributes.

This fixes the test suite when libvirt.so is built with CLang
with optimization enabled.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
21 files changed:
build-aux/mock-noinline.pl
src/check-symfile.pl
src/internal.h
src/qemu/qemu_capspriv.h
src/rpc/virnetsocket.h
src/util/vircommand.h
src/util/vircrypto.h
src/util/virfile.h
src/util/virhostcpu.h
src/util/virmacaddr.h
src/util/virnetdev.h
src/util/virnetdevip.h
src/util/virnetdevopenvswitch.h
src/util/virnetdevtap.h
src/util/virnuma.h
src/util/virrandom.h
src/util/virscsi.h
src/util/virscsivhost.h
src/util/virtpm.h
src/util/virutil.h
src/util/viruuid.h