gcc-4.1 vs gcc-4.3 and multiple "tolower"/"toupper" refs

Robert P. J. Day rpjday at crashcourse.ca
Sun Feb 22 17:15:38 UTC 2009


On Sun, 22 Feb 2009, Bernd Petrovitsch wrote:

> On Son, 2009-02-22 at 11:20 -0500, Robert P. J. Day wrote:
> > On Sun, 22 Feb 2009, Bernd Petrovitsch wrote:
> > > On Son, 2009-02-22 at 07:19 -0500, Robert P. J. Day wrote:
> > > [...]
> > > >    i'm confused ... why should upgrading my toolchain suddenly result
> > > > in the definition of text symbols "tolower" and "toupper" in various
> > > > object files, causing a link error?
> > >
> > > Can you dig out the definitions/declarations/#defines tolower() and
> > > toupper() which are actually used?
> >
> >   as in, where those are defined in the toolchain?  i'd thought of
>
> These functions are part of the C standard (see e.g.
> http://www.opengroup.org/onlinepubs/009695399/functions/toupper.html for
> this).
> So they can be found in e.g. /usr/include/ctype.h.

  i know.  as a test, i created a trivial "tolower.c" file and
cross-compiled it directly with the aforementioned gcc-4.3 coldfire
compiler.  running "nm" on the resulting executable gives me:

...
       U tolower@@GLIBC_2.4
...

which is precisely what i expected to see -- an undefined reference to
"tolower" which will later be resolved at run-time.

  the additional complication here is that this entire (cross-compile)
build is being down within a utility called "LTIB" from freescale
which "wraps" (sort of) all of the cross-compile utilities so that
they appear to be invoked simply via "gcc", "ld" and so on.  thus,
everything that's being compiled doesn't need to be told about a
cross-compiler -- they all think they're just compiling natively.

  in any event, it's still a mystery why these invocations of
tolower() and toupper() don't translate to external references, but
rather to what appear to be some kind of external linkage inline,
whereupon the final link step fails horribly.

  more research to follow.

> Another approach is to run only the preprocessor (read: `gcc -E`) and
> see what remains on the call sites of the functions (and see if there is
> a difference).
> The somewhat "brute force" solution is to add
> ----  snip  ----
> #define	toupper(c)	(((c)>='a'&&(c)<='z') ? (c)^0x20 : (c))
> ----  snip  ----
> (or a similar inline function) to busybox itself.
>
> 	Bernd
>
> PS: Obviously the above applies to tolower too which is left out for the
>     sake of simplicity.

  sadly, there are a number of trivial tests that i can't do because
of this LTIB wrapping feature.

rday
--

========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry:
    Have classroom, will lecture.

http://crashcourse.ca                          Waterloo, Ontario, CANADA
========================================================================


More information about the busybox mailing list