Bug 1505608 - Try to ensure the bss section of the elfhack testcase stays large enoug...
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 8 Nov 2018 14:50:22 +0000 (14:50 +0000)
committerMike Hommey <glandium@debian.org>
Tue, 11 Dec 2018 23:29:04 +0000 (23:29 +0000)
In bug 1470701, we added a dummy global variable so that it ends up in
the bss section, making it large enough for two pointers. Unfortunately,
in some cases, the symbol is eliminated by the linker because it is
unused. So we try to ensure it stays there.

Differential Revision: https://phabricator.services.mozilla.com/D11257

Gbp-Pq: Topic fixes
Gbp-Pq: Name Bug-1505608-Try-to-ensure-the-bss-section-of-the-elf.patch

build/unix/elfhack/test.c

index 8c66c19631d1444f4bfb2654aa085aa9cf48728b..e543b48fff46e2d6a0e34d500ba03950212124fe 100644 (file)
@@ -136,8 +136,12 @@ size_t dummy;
 void end_test() {
     static size_t count = 0;
     /* Only exit when both constructors have been called */
-    if (++count == 2)
+    if (++count == 2) {
         ret = 0;
+        // Avoid the dummy variable being stripped out at link time because
+        // it's unused.
+        dummy = 1;
+    }
 }
 
 void test() {