Re: undefined reference to `memset'

From: Bruce Evans (bde_at_zeta.org.au)
Date: 03/25/05

  • Next message: Bruce Evans: "Re: undefined reference to `memset'"
    Date: Fri, 25 Mar 2005 13:28:13 +1100 (EST)
    To: Nick Barnes <Nick.Barnes@pobox.com>
    
    

    On Thu, 24 Mar 2005, Nick Barnes wrote:

    > At 2005-03-24 08:31:14+0000, Bruce Evans writes:
    >
    >> what is gcc to do when -fno-builtin tells it to turn off its
    >> builtins and -ffreestanding tells it that the relevant interfaces
    >> might not exist in the library?
    >
    > Plainly, GCC should generate code which fills the array with zeroes.
    > It's not obliged to generate code which calls memset (either builtin
    > or in a library). If it knows that it can do so, then fine.
    > Otherwise it must do it the Old Fashioned Way. So this is surely a
    > bug in GCC.
    >
    > Nick B, who used to write compilers for a living

    But the compiler can require the Old Fashioned Way to be in the library.

    libgcc.a is probably part of gcc even in the freestanding case. The
    current implementation of libgcc.a won't all work in the freestanding
    case, since parts of it call stdio, but some parts of it are needed
    and work (e.g., __divdi3() on i386's at least). The kernel doesn't
    use libgcc.a, but it knows that __divdi3() and friends are needed and
    implements them in its libkern. Strictly, it should do something
    similar for memset().

    I think the only bugs in gcc here are that the function it calls is
    in the application namespace in the freestanding case, and that the
    requirements for freestanding implementations are not all documented.
    The requirement for memset() and friends _is_ documented (in gcc.info),
    but the requirement for __divdi3() and friends are only documented
    indirectly by the presence of these functions in libgcc.a.

    Bruce
    _______________________________________________
    freebsd-stable@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-stable
    To unsubscribe, send any mail to "freebsd-stable-unsubscribe@freebsd.org"


  • Next message: Bruce Evans: "Re: undefined reference to `memset'"

    Relevant Pages

    • Re: [PATCH] Dont compare unsigned variable for <0 in sys_prctl()
      ... is the _right_ way to do things, without having to carry stupid context ... generate good code) notices that the fact that "x" is unsignes means that ... Gcc warns for a lot of wrong things. ... Friends don't let friends use "-W". ...
      (Linux-Kernel)
    • Re: C container and persistent library ?
      ... (you wont win friends here by implying that C is an inferior cousin to ... Try gcc then. ...
      (comp.lang.c)
    • Re: New
      ... >>> GCC ... >>> (GNU Compiler Collection), but I really recommend you to take another ... >>that maybe your friends can still help you somewhat. ...
      (comp.programming)
    • Re: CodeWarrior for Mac Roadmap
      ... > I would suggest you look again at the gcc stl. ... I have friends who work ... > on it, and well, they think it is tops! ...
      (comp.sys.mac.programmer.codewarrior)