diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /build/pure_virtual/pure_virtual.c | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'build/pure_virtual/pure_virtual.c')
-rw-r--r-- | build/pure_virtual/pure_virtual.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/build/pure_virtual/pure_virtual.c b/build/pure_virtual/pure_virtual.c new file mode 100644 index 0000000000..23b18f2aae --- /dev/null +++ b/build/pure_virtual/pure_virtual.c @@ -0,0 +1,27 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include <mozilla/Assertions.h> + +// This function is used in vtables to point at pure virtual methods. +// The implementation in the standard library usually aborts, but +// the function is normally never called (a call would be a bug). +// Each of these entries in vtables, however, require an unnecessary +// dynamic relocation. Defining our own function makes the linker +// point the vtables here instead of the standard library, replacing +// the dynamic relocations with relative relocations. +// +// On Windows, it doesn't really make a difference, but on macOS it +// can be packed better, saving about 10KB in libxul, and on 64-bits +// ELF systems, with packed relative relocations, it saves 140KB. +// +// Another advantage of having our own is that we can use MOZ_CRASH +// instead of the system's abort. +#ifdef _MSC_VER +int __cdecl _purecall() { MOZ_CRASH("pure virtual call"); } +#else +__attribute__((visibility("hidden"))) void __cxa_pure_virtual() { + MOZ_CRASH("pure virtual call"); +} +#endif |