Operating System - OpenVMS
1827701 Members
2977 Online
109967 Solutions
New Discussion

Re: External symbol size mismatch between C and Fortran on IA64

 
Glenn Wolf
Advisor

External symbol size mismatch between C and Fortran on IA64

I have an issue porting from Alpha to Itanium with the size of external symbol names between C and Fortran:

A fortran module declares a function with a name that is 33 characters long. A C program is calling this function. When linking, the linker emits:
%ILINK-W-USEUNDEF, undefined symbol SSPLIS_LOTINFOUTIL_DISPATCHSTRI referenced
section: $CODE$
offset: %X000000000000A400 slot: 2
module: TPSTATSHTTP

The fortran module is compiled with the default for /NAMES (which I don't think controls the length).

The C module is compiled with the default for /NAMES (UPPERCASE,TRUNCATED).

I don't see any combination of /NAMES which will result in a match for the linker. In C, I can only choose Truncated or Shortened, and AS_IS only applies to case, not to length. Fortran provides no control that I can find over the length of externals.

Please direct me to the post if this has been answered before.

Thanks;

Glenn
11 REPLIES 11
Steven Schweda
Honored Contributor

Re: External symbol size mismatch between C and Fortran on IA64

The obvious asnwer would be CC /NAMES =
NOTRUNCATE, but:

$ cc /names=notruncate
%DCL-W-NOTNEG, qualifier or keyword not negatable - remove "NO" or omit
\NOTRUNCATE\

Starting to smell like a feature request. A
little ANAL /OBJE action on some simple test
files does suggest that Fortran can create a
longer-than-31-character external name:

[...]
6) Global Symbol Specification (EGSD$C_SYM)
[...]
symbol: "THIS__NAME__IS__36__CHARACTERS__LONG"
[...]

Perhaps someone who knows something will
offer an actual solution, but to me, you sure
look doomed.
Steven Schweda
Honored Contributor

Re: External symbol size mismatch between C and Fortran on IA64

Of course, I was on an Alpha, but they're
compatible, right?
Richard Whalen
Honored Contributor

Re: External symbol size mismatch between C and Fortran on IA64

Alpha and IA64 use very different object (and image) file formats. IA64 uses something called ELF/DWARF.

But, I had no problem getting FORTRAN to generate a symbol with a long name.

000003D8 000000D8 Symbol 9. (00000009) "THIS__NAME__IS__36__CHARACTERS__LONG"
000003D8 000000D8 Name Index in Sec. 11.: 00000049 73.
000003DC 000000DC Symbol Info Field: 12 symtab$b_st_info
Symbol Type: 02 STT_FUNC
Symbol Binding: 01 STB_GLOBAL
000003DD 000000DD Symbol 'Other' Field: 00 symtab$b_st_other
Symbol Visibility 00 STV_DEFAULT
000003DE 000000DE Bound to section: 0006 6. "$CODE$" symtab$w_st_shndx
000003E0 000000E0 Symbol Value 0000000000000000 0. symtab$pq_st_value
000003E8 000000E8 Size associated with sym: 0000000000000010 symtab$q_st_size
Steven Schweda
Honored Contributor

Re: External symbol size mismatch between C and Fortran on IA64

> But, I had no problem getting FORTRAN to
> generate a symbol with a long name.

Great. Neither did I. Now, if you can get
C to do it, too, you'll have the problem
solved.
Richard Whalen
Honored Contributor

Re: External symbol size mismatch between C and Fortran on IA64

The way that I read the help text below, the C compilier is always going to make sure that external names are no longer than 31 characters. The choice that you have is whether they are truncated (default) or shortened to the first 24 characters with a 7 character CRC.

The FORTRAN names qualifier only allows one to control the case used (upper, lower, as_is).

It seems to me that this is one of the instances in which changes need to be made to the source to do the port from Alpha to Itanium.


CC

/NAMES

/NAMES=(option1,option2)
/NAMES=(UPPERCASE,TRUNCATED) (D)

Option1 converts all definitions and references of external symbols
and psects to the specified case:

o /NAMES=UPPERCASE (default) converts to uppercase.

o /NAMES=AS_IS leaves the case unchanged.

Option2 controls whether or not long external names greater than 31
characters get truncated or shortened:

o /NAMES=TRUNCATED (default) truncates long external names

o /NAMES=SHORTENED shortens long external names.

A shortened name consists of the first 24 characters of the
name followed by a 7-character Cyclic Redundancy Check (CRC)
computed by looking at the full name.

By default, the compiler issues a warning and truncates the name to
31 characters.

The /NAMES qualifier does not affect the names of the $ABS$, $BSS$,
$CODE$, $DATA$, $LINK$, $LITERAL$, and $READONLY$ psects.
Glenn Wolf
Advisor

Re: External symbol size mismatch between C and Fortran on IA64

I neglected to supply system and compiler versions, and this appears to be a difference between F77 and F90:
Itanium system:
OpenVMS V8.3, HP Fortran V8.1-1-104930-50GBS, HP C V7.2-001 on OpenVMS IA64 V8.3

Working on my alpha systems, the linker resolves this symbol (well, most of it) correctly in both of these environments:
OpenVMS V7.3-2, HP Fortran 77 V7.6-198-48D52 on OpenVMS Alpha V7.3-2, Compaq C V6.5-001 on OpenVMS Alpha V7.3-2 and
OpenVMS V8.2, HP Fortran 77 V8.0-198-48F7C on OpenVMS Alpha V8.2, HP C V7.1-015 on OpenVMS Alpha V8.2

F77 on Alpha (OpenVMS 8.2; I don't have an 8.3 alpha system) creates symbols truncated to 31 characters:
6) Global Symbol Specification (EGSD$C_SYM)
data type: DSC$K_DTYPE_Z (0)
symbol flags:
(0) EGSY$V_WEAK 0
(1) EGSY$V_DEF 1
(2) EGSY$V_UNI 0
(3) EGSY$V_REL 1
(4) EGSY$V_COMM 0
(5) EGSY$V_VECEP 0
(6) EGSY$V_NORM 1
psect: 4
value: 56 (%X'00000038')
code address psect: 3
code address: 0 (%X'00000000')
symbol: "SSPLIS_LOTINFOUTIL_DISPATCHSTRI"

whereas F90 (on Itanium) defines the entire symbol:
00001DB8 00000198 Symbol 17. (00000011) "SSPLIS_LOTINFOUTIL_DISPATCHSTRING"
00001DB8 00000198 Name Index in Sec. 11.: 00000025 37.
00001DBC 0000019C Symbol Info Field: 12 symtab$b_st_info
Symbol Type: 02 STT_FUNC
Symbol Binding: 01 STB_GLOBAL
00001DBD 0000019D Symbol 'Other' Field: 00 symtab$b_st_other
Symbol Visibility 00 STV_DEFAULT
00001DBE 0000019E Bound to section: 0006 6. "$CODE$" symtab$w_st_shndx
00001DC0 000001A0 Symbol Value 0000000000000000 0. symtab$pq_st_value
00001DC8 000001A8 Size associated with sym: 0000000000001080 symtab$q_st_size


Which reminds me of another issue:
The long-named function in Fortran is contained in a source file which also contains about 6 other subroutines and functions (it being the last one in the file). When I do Analyze/object on the F90 output (on Itanium), it only reports informtion on some of the modules. To get the above analyze/object output, I had to copy the function out into a source file containing only that function, compile and analyze/object that file. Sometimes (dependent on what sections I chose???) I would get analysis output for only the first module in the source file; other times it would give me the first 3 (of 7) modules.

If this has been answered, please point me to that entry; otherwise, I'll start a new thread on this one.
Steven Schweda
Honored Contributor

Re: External symbol size mismatch between C and Fortran on IA64

> It seems to me that this is one of the
> instances in which changes need to be made
> to the source to do the port from Alpha to
> Itanium.

I don't see an Alpha-IA64 difference here,
only a C-Fortran difference.
Glenn Wolf
Advisor

Re: External symbol size mismatch between C and Fortran on IA64

>> It seems to me that this is one of the
>> instances in which changes need to be made
>> to the source to do the port from Alpha to
>> Itanium.
>
>I don't see an Alpha-IA64 difference here,
>only a C-Fortran difference.

I agree that this is an F77/F90 vs C compatibility issue, but it may be only present on Itanium (due to the ELF object format, and the Intel compiler back end); I don't have F90 on alpha to test (Perhaps Steven/Richard could reference their "THIS__NAME__IS__36__CHARACTERS__LONG" fortran symbol from a C routine and see if the alpha linker truncates the def??)

I've written a jacket routine in fortran whose name fits in 31 characters, and calls SSPLIS_LOTINFOUTIL_DISPATCHSTRING, which resolved the undefined symbol. Fortunately in all the code I'm porting, I've only seen this one symbol that is too long. I'd hate to have to do that for dozens or hundreds of symbols. I have some C++ stuff to do later
and those names are notorious for their length. I'm holding my breath.
Steven Schweda
Honored Contributor

Re: External symbol size mismatch between C and Fortran on IA64

> [...] but it may be only present on
> Itanium [...]

On my Alpha, Fortran 90 easily gives a
36-character global symbol, as shown before.

Fortran 77 complains:

alp $ fortran /old_f77 TRUNF.FOR

function this__name__is__36__characters__long()
...............^
%FORT-W-NAMTOOLON, Name longer than 31 characters
at line number 1 in file ALP$DKA0:[SMS]TRUNF.FOR;3
[...]

I see no way to get DEC/Compaq/HP C to emit
a global symbol longer than 31 characters,
but I'm always open to enlightenment.

> I have some C++ stuff to do later
> and those names are notorious for their
> length. [...]

And for the name-mangling which is done to
shorten them when they go global.

HELP CXXDEMANGLE

Around here:

alp $ fortran /version
HP Fortran V7.6-3276-48D52
alp $ fortran /old_f77 /version
HP Fortran 77 V7.6-198-48D52 on OpenVMS Alpha V7.3-2
alp $ cc /version
HP C V7.1-015 on OpenVMS Alpha V7.3-2

(But a quick check of "HP C V7.3-018 on
OpenVMS IA64 V8.3" on a TestDrive system
didn't reveal any new /NAMES options.)
Richard Whalen
Honored Contributor

Re: External symbol size mismatch between C and Fortran on IA64

Analyze/object or /image on IA64 only does part of the file because IA64 objects & images are so big. I always use /section=all and do it to a file so that I can find what I want.
Glenn Wolf
Advisor

Re: External symbol size mismatch between C and Fortran on IA64

I've started a new thread on the Analyze/Object question. Please post replies to that thread.

Thanks!

Glenn