09 Mar, 2016

1 commit

  • When running sandbox, the following phases occur, each with different
    malloc implementations or behaviors:

    1) Dynamic linker execution, using the dynamic linker's own malloc()
    implementation. This is fully functional.

    2) After U-Boot's malloc symbol has been hooked into the GOT, but before
    any U-Boot code has run. This phase is entirely non-functional, since
    U-Boot's gd symbol is NULL and U-Boot's initf_malloc() and
    mem_malloc_init() have not been called.

    At least on Ubuntu Xenial, the dynamic linker does make both malloc() and
    free() calls during this phase. Currently these free() calls crash since
    they dereference gd, which is NULL.

    U-Boot itself makes no use of malloc() during this phase.

    3) U-Boot execution after gd is set and initf_malloc() has been called.
    This is fully functional, albeit via a very simple malloc()
    implementation.

    4) U-Boot execution after mem_malloc_init() has been called. This is fully
    functional with a complete malloc() implementation.

    Furthermore, if code that called malloc() during phase 1 calls free() in
    phase 3 or later, it is likely that heap corruption will occur, since
    U-Boot's malloc implementation will assume the pointer is part of its own
    heap, although it isn't. I have not actively observed this happening.

    To prevent phase 2 from happening, this patch makes all of U-Boot's malloc
    library public symbols have hidden visibility. This prevents them from
    being hooked into the GOT, so only code in the U-Boot binary itself
    actually calls them; any other code will call into the standard C library
    malloc(). This also avoids the "furthermore" issue mentioned above.

    I have seen references to this GCC pragma in blog posts from 2008, and
    RHEL5's ancient gcc appears to accept it fine, so I believe it's quite
    safe to use it without checking gcc version.

    Cc: Rabin Vincent
    Signed-off-by: Stephen Warren
    Reviewed-by: Tom Rini
    Reviewed-by: Simon Glass

    Stephen Warren
     

21 Oct, 2015

1 commit

  • common/dlmalloc.c is quite big, both in .text and .data usage, therefor
    on some boards the SPL is build to use only malloc_simple.c and not the
    dlmalloc.c code. This is done in various include/configs/foo.h with the
    following construct:

    #ifdef CONFIG_SPL_BUILD
    #define CONFIG_SYS_MALLOC_SIMPLE
    #endif

    This commit introduces a SPL_MALLOC_SIMPLE Kconfig bool which allows
    selecting this functionality through Kconfig instead.

    Signed-off-by: Hans de Goede
    Acked-by: Simon Glass

    Hans de Goede
     

23 Apr, 2015

1 commit


21 Nov, 2014

1 commit

  • The simple malloc() implementation is used when memory is tight. It provides
    a simple buffer with an incrementing pointer.

    At present the implementation is inside dlmalloc. Move it into its own file
    so that it is easier to find.

    Rather than using relocation as a signal that the full malloc() is
    available, add a special GD_FLG_FULL_MALLOC_INIT flag. This signals that the
    simple malloc() should no longer be used.

    In some cases, such as SPL, even the code space used by the full malloc() is
    wasteful. Add a CONFIG_SYS_MALLOC_SIMPLE option to provide only the simple
    malloc. In this case the full malloc is not available at all. It saves about
    1KB of code space and about 0.5KB of data on Thumb 2.

    Acked-by: Tom Rini
    Signed-off-by: Simon Glass

    Simon Glass
     

02 Apr, 2013

1 commit

  • 'bool' is defined in random places. This patch consolidates them into a
    single header file include/linux/types.h, using stdbool.h introduced in C99.

    All other #define, typedef and enum are removed. They are all consistent with
    true = 1, false = 0.

    Replace FALSE, False with false. Replace TRUE, True with true.
    Skip *.py, *.php, lib/* files.

    Signed-off-by: York Sun

    York Sun
     

20 Feb, 2013

1 commit

  • On architectures where manual relocation
    is needed, the 'malloc_bin_reloc' function
    must be called after 'mem_malloc_init'.

    Make the 'malloc_bin_reloc' function static
    and call it directly from 'mem_malloc_init'
    instead of calling that from board_init_{r,f}
    functions of the affected architectures.

    Signed-off-by: Gabor Juhos
    Cc: Wolfgang Denk
    Cc: Andreas Bießmann
    Cc: Jason Jin
    Cc: Macpaul Lin
    Cc: Daniel Hellstrom
    Cc: Daniel Schwierzeck

    Gabor Juhos
     

27 Sep, 2012

1 commit


10 Aug, 2012

1 commit

  • In file included from arch/arm/lib/board.c:43:0:
    include/malloc.h:490:5: warning: "HAVE_MMAP" is not defined [-Wundef]
    include/malloc.h:590:5: warning: "HAVE_USR_INCLUDE_MALLOC_H" is not defined [-Wundef]
    include/malloc.h:757:5: warning: "HAVE_MMAP" is not defined [-Wundef]

    Signed-off-by: Marek Vasut
    Cc: Wolfgang Denk

    Marek Vasut
     

10 Sep, 2011

1 commit

  • assert() is like BUG_ON() but compiles to nothing unless DEBUG is defined.
    This is useful when a condition is an error but a board reset is unlikely
    to fix it, so it is better to soldier on in hope. Assertion failures should
    be caught during development/test.

    It turns out that assert() is defined separately in a few places in U-Boot
    with various meanings. This patch cleans up some of these.

    Build errors exposed by this change (and defining DEBUG) are also fixed in
    this patch.

    Signed-off-by: Simon Glass

    Simon Glass
     

05 Sep, 2009

2 commits


20 Jul, 2009

1 commit


28 Jun, 2003

1 commit

  • - remove trailing white space, trailing empty lines, C++ comments, etc.
    - split cmd_boot.c (separate cmd_bdinfo.c and cmd_load.c)

    * Patches by Kenneth Johansson, 25 Jun 2003:
    - major rework of command structure
    (work done mostly by Michal Cendrowski and Joakim Kristiansen)

    wdenk
     

03 Nov, 2002

1 commit