Date: Mon, 07 Dec 1998 10:25:21 -0600 From: Eric Rudd Subject: Re: libc math function upgrade work To: djgpp-workers AT delorie DOT com Message-id: <366C0171.AACE7F0@cyberoptics.com> Organization: CyberOptics MIME-version: 1.0 X-Mailer: Mozilla 4.05 [en] (Win95; U) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit References: <199810191414 DOT KAA25670 AT indy DOT delorie DOT com> <36696383 DOT 3E66693A AT cyberoptics DOT com> <199812051723 DOT MAA30930 AT envy DOT delorie DOT com> Reply-To: djgpp-workers AT delorie DOT com DJ Delorie wrote: > First off, I don't have a copy of the C9x spec. Is it official? How > do I get a copy? The home page for activities related to C9x is http://anubis.dkuug.dk/JTC1/SC22/WG14/ The standard has not yet issued, but the current draft is available at the above URL in several forms, pointed to at the above URL under the name "C9X FCD" The latest plain text version is at http://anubis.dkuug.dk/JTC1/SC22/WG14/www/docs/n843.txt It's about 1.4 MB. It's unlikely that any of the function names will change at this point. > > .globl ___pow2, _exp2 > > ___pow2: > > _exp2: > > ...code > > Normally, I'd say this was OK if both symbols were defined by the same > spec (i.e. rand() and srand() are in the same object, localtime() and > gmtime() are together), but in this case there might be a program that > is emulating C9x by providing its own exp2() function that calls > pow2(). If you tried to build such a program, you'd get link > failures. I can't see where there's a problem. Consider the following program: #include #include double exp2(double x) { return pow2(x); } int main(void) { printf("exp2(3) = %f\n", exp2(3.)); return 0; } The program compiled without errors using gcc -Wall test.c -o test.exe even though libc.a contained the function with the proposed double label _exp2 and ___pow2. The output was 8., as expected. If one changes the call inside the local exp2 to return pow10(x); one gets back 1000., instead of 8., which proves that it's linking in the __powXX labels, rather than the library _exp2 label. Since the user's function satisfies the external reference, the linker simply leaves the other libc function alone. I even tried putting the user exp2 function in a user library libtest.a, and linked it in with gcc -Wall test.c -o test.o -ltest and it still the same as discussed above. So I'm still puzzled by your reservations. If, indeed, there is a problem with a global label, I would expect the stub mechanism to fail also, since the stub would contain the same global label _exp2 that you think may cause problems. Am I missing something obvious? -Eric Rudd