https://gcc.gnu.org/g:2f4e06842580aad43e2d9d6aec77d24c06a383d8

commit r17-4720-g2f4e06842580aad43e2d9d6aec77d24c06a383d8
Author: Xavier Del Campo Romero <[email protected]>
Date:   Fri Sep 25 00:29:18 2026 +0200

    cobol: Add -export-dynamic by default
    
    If a program built with -fno-static-call CALLs another program within
    the same executable, the CALL can fail with the following warning
    message:
    
    WARNING: prog.cbl:4 "CALL foo" not found with no "CALL ON EXCEPTION" phrase.
    (You might need -rdynamic or --export-dynamic for symbols in the 
executable.)
    
    The default behaviour for gcc is *not* to export unreferenced symbols to
    the dynamic symbol table. Since -fno-static-call is in effect by default
    in gcobc(1), this can cause programs within the same executable not to
    have any references to them because CALLs are deferred to dlopen(3) and
    dlsym(3), and are therefore discarded from the table, potentially
    triggering the warning message above.
    
    Therefore, -export-dynamic mitigates this by exporting all symbols,
    included unreferenced ones.
    
    gcc/cobol/ChangeLog:
    
            * gcobc: Add -export-dynamic.

Diff:
---
 gcc/cobol/gcobc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/cobol/gcobc b/gcc/cobol/gcobc
index 1b125342d537..b967428076d0 100755
--- a/gcc/cobol/gcobc
+++ b/gcc/cobol/gcobc
@@ -568,7 +568,8 @@ done
 # cobc default:
 if [ "$static_used" = "" ]
 then
-    opts="-fno-static-call $opts";
+    # -export-dynamic required if CALLs occur within the same executable.
+    opts="-fno-static-call -export-dynamic $opts";
 fi
 
 if [ "$exit_status" -gt 0 ]

Reply via email to