https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119414
--- Comment #13 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to rdubner from comment #11)
> IDENTIFICATION DIVISION.
> PROGRAM-ID. caller.
> PROCEDURE DIVISION.
> CALL "callee1" ON EXCEPTION
> CALL "callee2" ON EXCEPTION
> DISPLAY "neither callee1 nor callee2 found"
> END-CALL
> END-CALL
> GOBACK.
> END PROGRAM caller.
> IDENTIFICATION DIVISION.
> PROGRAM-ID. callee2.
> PROCEDURE DIVISION.
> DISPLAY "this is callee2" NO ADVANCING
> GOBACK.
> END PROGRAM callee2.
>
> The instruction CALL "callee1" ON EXCEPTION means that if "callee1" can't be
> found, then execute the code following "ON EXCEPTION" until the enclosing
> END-CALL is encountered.
>
> There is no callee1 to be found; there are no DSOs involved. As you can see
> callee2 is part of the source code module.
>
> When compiled with "gcobol playpen.cbl", the result is a static linking
> error:
>
> /usr/bin/ld: /tmp/ccqZ2tzw.o: in function
> `_para._implicit_paragraph_5._initialize_program.caller.0.67':
> playpen.cbl:(.text+0x399): undefined reference to `callee1'
So, I'd suggest to use weak symbol here for callee1.
That matches what would happen for C/C++
#include <stdio.h>
extern void callee1(void) __attribute__((weak));
void callee2(void) { printf ("this is callee2"); }
int main () { if (callee1) callee1 (); else if (callee2) callee2 (); else
printf ("neither callee1 nor callee2 found"); }
callee2 doesn't have to be weak because it is defined in the current TU.