[OpenVMS, Linker] Creating universal symbols aliases

SYMPTOM/SOLUTION:
PRODUCT: Linker
OP/SYS: OpenVMS Alpha and Itanium
COMPONENT: Universal symbols
SOURCE: Philippe Vouters Fontainebleau/France
HIGH QUALITY SUPPORT: http://vouters.dyndns.org
SYMPTOM(S) or PROBLEM(S): Who did not silently wonder how the DECC RTL could define its symbols such as decc$open in both lower and uppercase. Which hint is being used here ?
SOLUTION or RESPONSE: The DECC RTL ought to be using the universal symbols alias feature which is available as a Linker's SYMBOL_VECTOR option. Here is the full Linker's option file corresponding to the demonstration below. $ type libfoo.opt CASE_SENSITIVE=YES SYMBOL_VECTOR=(foo=PROCEDURE) SYMBOL_VECTOR=(FOO/foo=PROCEDURE) With this option file, foo and FOO are both possible symbols representing the foo() routine in libfoo.c.
ALTERNATIVE: Code your shared library source code with both lower and uppercased entry points and add SYMBOL_VECTOR=(x=PROCEDURE) for each of the lower and uppercased symbols.
DEMONSTRATION: We will use the HP C compiler to demonstrate this. $ show system/noprocess OpenVMS V8.3-1H1 on node THESEE 9-NOV-2012 19:46:45.58 Uptime 359 03:53:49 $ pipe product show history | search sys$pipe: update ... HP I64VMS VMS831H1I_UPDATE V4.0 Patch Install Val 05-JUL-2009 ... $ create libfoo.c void foo(){ } $ cc/names=(as_is) libfoo $! $! The HP compiler only generated "foo" entry point in lowercase. $! This is proved by this piped command. $! $ pipe nm libfoo.obj | search/EXACT sys$pipe: " T " 0000000000000000 T foo $! $ create libfoo.opt CASE_SENSITIVE=YES SYMBOL_VECTOR=(foo=PROCEDURE) SYMBOL_VECTOR=(FOO/foo=PROCEDURE) $! $ link/share libfoo,libfoo.opt/options $! $! Here is what the Linker generates with our option file. $! So foo and FOO universal symbols are generated by the $! the OpenVMS Linker. $! $ nm libfoo.exe 0000000000000001 A FOO 0000000000000000 A foo $! $! Looking after a full demo. $! $ create main.c /* * This code is intentionally written in C * and compiled with /names=(as_is) */ extern void foo(); extern void FOO(); void main(){ foo(); FOO(); } $ cc/names=(as_is) main.c $ link main,sys$input:/options sys$disk:[]libfoo/share $! $! So strictly no undefined symbols $! $ define libfoo sys$disk:[]libfoo.EXE $ run main $! $! From the above, strictly no runtime problem $! calling foo and FOO. $!
REFERENCE: http://h71000.www7.hp.com/doc/83final/4548/4548pro_021.html As an information complement, read Hartmut Becker's appropriate add-on proving afterwards that this demonstration matches the theory at: http://h30499.www3.hp.com/t5/Languages-and-Scripting/In-case-this-interests-someone-in-the-VMS-land/td-p/5857767#.UJmCj-OmJEk
Did you find this helpful?