uboot/include
Stephen Warren 2f0bcd4de1 malloc: use hidden visibility
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 <rabin@rab.in>
Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2016-03-08 15:01:47 -05:00
..
andestech
asm-generic Remove unused CONFIG_MODEM_SUPPORT option and associated dead code. 2016-02-08 10:22:44 -05:00
bedbug
cavium armv8: cavium: Add an implementation of ATF calling functions 2016-01-19 22:26:12 +00:00
configs OMAP3: am3517_evm: Add NAND MTD partitions with UBI/UBIFS support 2016-03-08 15:00:40 -05:00
cramfs
dm stm32x7: add support for stm32x7 serial driver 2016-02-24 18:43:54 -05:00
dt-bindings tegra: dts: Sync up the tegra124 device tree files with Linux 2016-02-16 09:17:50 -07:00
faraday
fsl-mc driver: net: fsl-mc: flib changes for MC FW 9.0.0 2016-01-27 08:13:10 -08:00
grlib sparc: leon3: Moved GRLIB core header files to common include/grlib directory 2015-11-13 10:23:33 +02:00
jffs2
linux compiler*.h: sync include/linux/compiler*.h with Linux 4.5-rc6 2016-02-29 11:43:24 -05:00
lzma
mtd cfi_flash: use specific width types for cword 2015-10-27 11:51:53 +01:00
net
pcmcia
power pmic: tps65218: add useful functions and defines 2016-02-24 18:44:07 -05:00
samsung exynos5-dt-types: add board detection for Odroid XU3/XU3L/XU4. 2015-11-02 10:38:00 +09:00
synopsys
test
u-boot Add more SPDX-License-Identifier tags 2016-01-19 08:31:21 -05:00
usb Add more SPDX-License-Identifier tags 2016-01-19 08:31:21 -05:00
zfs
.gitignore
ACEX1K.h
MCD_dma.h
MCD_progCheck.h
MCD_tasksInit.h
SA-1100.h
_exports.h malloc_simple: Add Kconfig option for using only malloc_simple in the SPL 2015-10-20 18:40:27 +02:00
adc.h dm: adc: add simple ADC uclass implementation 2015-11-02 10:38:00 +09:00
addr_map.h Add more SPDX-License-Identifier tags 2016-01-19 08:31:21 -05:00
aes.h
ahci.h dm: ahci: Convert to use new DM PCI API 2016-01-12 10:19:09 -07:00
ali512x.h
altera.h
ambapp.h sparc: leon3: Moved GRLIB core header files to common include/grlib directory 2015-11-13 10:23:33 +02:00
ambapp_ids.h sparc: leon3: Moved GRLIB core header files to common include/grlib directory 2015-11-13 10:23:33 +02:00
android_image.h
ansi.h
api_public.h
armcoremodule.h
asm-offsets.h
ata.h
atmel_hlcdc.h
atmel_lcd.h
atmel_lcdc.h
atmel_mci.h
autoboot.h
axp152.h sunxi: power: Unify axp pmic function names 2015-10-20 18:40:27 +02:00
axp209.h sunxi: power: Add support for disabling axp209 regulators 2015-10-20 18:40:27 +02:00
axp221.h sunxi: Implement poweroff support for axp221 pmic 2016-01-26 16:20:04 +01:00
axp818.h power: axp818: Remove duplicate register definition macros 2016-01-26 16:20:05 +01:00
axp_pmic.h power: axp: merge separate DLDO functions into 1 2016-01-26 16:20:05 +01:00
backlight.h dm: backlight: Add a backlight uclass 2016-01-21 20:42:36 -07:00
bcd.h
bios_emul.h dm: pci: Convert bios_emu to use the driver model PCI API 2016-01-24 12:07:19 +08:00
bitfield.h
bmp_layout.h
bootcount.h
bootm.h
bootretry.h
bootstage.h
bouncebuf.h
bus_vcxk.h
bzlib.h bzip2: Support compression for sandbox 2016-01-20 19:06:23 -07:00
cbfs.h
circbuf.h
cli.h
cli_hush.h
clk.h dm: clk: Add support for decoding clocks from the device tree 2016-01-21 19:47:29 -07:00
cmd_spl.h
command.h cmd_boot: Add a poweroff command 2016-01-13 21:05:25 -05:00
common.h bug.h: move BUILD_BUG_* defines to include/linux/bug.h 2016-01-25 10:39:59 -05:00
common_timing_params.h Add more SPDX-License-Identifier tags 2016-01-19 08:31:21 -05:00
commproc.h
compiler.h Revert "include/linux: move typdef for uintptr_t" 2015-12-16 07:11:15 -05:00
config_cmd_all.h Remove unused CONFIG_CMD_HWFLOW option and associated dead code. 2016-02-08 10:22:44 -05:00
config_defaults.h
config_distro_bootcmd.h distro bootcmd: enumerate PCI before network operations 2016-01-28 21:01:23 -07:00
config_distro_defaults.h Use correct spelling of "U-Boot" 2016-02-06 12:00:59 +01:00
config_fallbacks.h
config_fsl_chain_trust.h secure_boot: split the secure boot functionality in two parts 2016-01-27 08:12:32 -08:00
config_phylib_all_drivers.h
config_uncmd_spl.h spl: dm: Add SPL_DM_SEQ_ALIAS config option 2016-01-13 13:20:02 +01:00
console.h console: Add a console buffer 2015-11-19 20:27:50 -07:00
cortina.h
cpsw.h drivers: net: cpsw: convert driver to adopt device driver model 2015-10-22 14:18:35 -04:00
cpu.h
crc.h
cros_ec.h cros_ec: Use udevice instead of cros_ec_dev for keyboard functions 2015-11-19 20:13:40 -07:00
cros_ec_message.h
dataflash.h
ddr_spd.h Add more SPDX-License-Identifier tags 2016-01-19 08:31:21 -05:00
debug_uart.h debug_uart: Add an option to announce the debug UART 2015-10-21 07:46:50 -06:00
dfu.h dfu: usb: f_dfu: Set deferred call for dfu_flush() function 2016-02-24 19:12:32 +01:00
dialog_pmic.h
display.h dm: video: Repurpose the 'displayport' uclass to 'display' 2016-01-21 20:42:36 -07:00
display_options.h
div64.h
dm-demo.h
dm.h
dm9000.h
dma.h dm: implement a DMA uclass 2016-02-23 16:14:45 +05:30
dp83848.h
ds1722.h
ds4510.h Add more SPDX-License-Identifier tags 2016-01-19 08:31:21 -05:00
dtt.h
dwc3-omap-uboot.h
dwc3-uboot.h
dwmmc.h mmc: dw_mmc: support fifo mode in dwc mmc driver 2015-12-01 08:07:22 -07:00
e500.h
ec_commands.h
edid.h dm: video: Repurpose the 'displayport' uclass to 'display' 2016-01-21 20:42:36 -07:00
efi.h
efi_api.h
elf.h
env_attr.h
env_callback.h
env_default.h
env_flags.h tools: env validate: pass values as 0-based array 2016-02-08 10:10:29 -05:00
environment.h
errno.h
ethsw.h drivers: net: vsc9953: Add LAG support 2016-01-28 12:22:19 -06:00
exports.h malloc_simple: Add Kconfig option for using only malloc_simple in the SPL 2015-10-20 18:40:27 +02:00
ext4fs.h
ext_common.h
exynos_lcd.h
fastboot.h fastboot: Move fastboot response functions to fastboot core 2015-11-12 13:17:31 -05:00
fat.h
fb_mmc.h fastboot: Implement flashing session counter 2015-11-12 13:17:32 -05:00
fb_nand.h fastboot: Implement NAND backend 2015-11-12 13:18:58 -05:00
fdt.h
fdt_simplefb.h
fdt_support.h
fdtdec.h tegra: nyan-big: Move the LCD driver to driver model 2016-02-16 09:17:51 -07:00
fis.h
flash.h cfi_flash: give default CONFIG_SYS_MAX_FLASH_SECT in flash.h 2015-11-30 13:00:00 +01:00
fm_eth.h net/fm: fix MDIO controller base on FMAN2 2015-10-29 10:34:00 -07:00
fpga.h fpga: Add bitstream type BIT_NONE 2016-01-27 15:55:54 +01:00
fs.h Add more SPDX-License-Identifier tags 2016-01-19 08:31:21 -05:00
fsl_csu.h armv7/ls1021a: move ns_access to common file 2015-10-29 10:33:58 -07:00
fsl_dcu_fb.h
fsl_ddr.h Add more SPDX-License-Identifier tags 2016-01-19 08:31:21 -05:00
fsl_ddr_dimm_params.h Add more SPDX-License-Identifier tags 2016-01-19 08:31:21 -05:00
fsl_ddr_sdram.h driver/ddr/fsl: Add workaround for A009663 2016-01-25 08:24:15 -08:00
fsl_ddrc_version.h
fsl_debug_server.h
fsl_devdis.h
fsl_diu_fb.h
fsl_dspi.h
fsl_dtsec.h net: Move some header files to include/ 2015-10-29 10:34:00 -07:00
fsl_errata.h fsl/ddr: updated ddr errata-A008378 for arm and power SoCs 2015-12-13 18:27:28 -08:00
fsl_esdhc.h ARM: imx: fsl_esdhc: fix usage of low 4 bits of sysctl register 2016-01-03 15:21:21 +01:00
fsl_fman.h fm: fdt: Move fman ucode fixup to driver code 2016-02-24 08:51:13 -08:00
fsl_ifc.h
fsl_immap.h
fsl_mdio.h net: tsec: fsl_mdio: Fix several cosmetic issues 2016-01-28 12:22:49 -06:00
fsl_memac.h
fsl_pmic.h
fsl_qe.h qe: move drivers/qe/qe.h to include/fsl_qe.h 2016-02-24 08:51:13 -08:00
fsl_sec.h imx: Refactoring CAAM Job Ring structure and Secure Memory for imx7 2016-02-21 11:20:54 +01:00
fsl_sec_mon.h
fsl_secboot_err.h
fsl_sfp.h
fsl_tgec.h net: Move some header files to include/ 2015-10-29 10:34:00 -07:00
fsl_usb.h drivers:usb:fsl: Add T4080 as affected soc for Erratum A007792 sw workaround 2015-12-07 00:14:59 +01:00
fsl_validate.h secure_boot: enable chain of trust for ARM platforms 2016-01-27 08:12:49 -08:00
fsl_wdog.h imx_watchdog: always set minimal timeout in reset_cpu 2016-01-07 17:54:53 +01:00
fuse.h
g_dnl.h
gdsys_fpga.h hrcon: Add support for the DH variant 2015-11-12 18:04:10 -05:00
gt64120.h
hash.h hash.c: Conditionally compile hash_command, static hash_show 2016-01-13 21:05:08 -05:00
hw_sha.h
hwconfig.h
i2c.h i2c: Fix the comment to match the function described 2015-11-27 05:54:21 +01:00
i2c_eeprom.h
i2s.h
i8042.h input: Convert i8042 to driver model 2015-11-19 20:13:41 -07:00
ide.h block: pass block dev not num to read/write/erase() 2016-01-13 21:05:18 -05:00
image-sparse.h sparse: Rename the file and header 2015-11-12 13:18:59 -05:00
image.h image: Correct the OS location code to work on sandbox 2016-02-26 08:53:10 -07:00
imx_thermal.h
initcall.h
input.h input: Change LED state bits to conform i8042 compatible keyboard 2015-11-19 20:13:42 -07:00
inttypes.h
iomux.h
ioports.h
iotrace.h
ipu_pixfmt.h
key_matrix.h
keyboard.h input: Convert 'keyboard' driver to use input library 2015-11-19 20:13:41 -07:00
kgdb.h
lattice.h
lcd.h lcd: fix the color testpattern in 16bit mode 2016-01-24 00:38:40 +01:00
lcd_console.h
lcdvideo.h
ld9040.h
led-display.h
led.h
libata.h
libfdt.h
libfdt_env.h
libtizen.h
linker_lists.h
linux_logo.h
lmb.h
logbuff.h
lxt971a.h
lynxkdi.h
malloc.h malloc: use hidden visibility 2016-03-08 15:01:47 -05:00
mapmem.h
mb862xx.h
mc9sdz60.h
mc13783.h
mc13892.h
mc34704.h
memalign.h
membuff.h Add a circular memory buffer implementation 2015-11-19 20:27:50 -07:00
menu.h
micrel.h
mii_phy.h
miiphy.h net: mdio: Add mdio_free() and mdio_unregister() API 2015-10-29 14:05:50 -05:00
mipi_display.h
misc.h include: Correct "requset" typoes in misc.h 2016-01-08 10:15:42 -05:00
mk48t59.h
mmc.h mmc: add missing prototype for mmc_get_env_dev 2016-02-01 17:08:44 -05:00
mpc5xx.h
mpc5xxx.h
mpc5xxx_sdma.h
mpc8xx.h
mpc8xx_irq.h
mpc83xx.h powerpc/83xx: fix build failure 2016-01-20 10:19:40 -05:00
mpc85xx.h
mpc86xx.h
mpc106.h
mpc823_lcd.h
mpc8260.h Replace "extern inline" with "static inline" 2015-11-09 18:19:40 -05:00
mpc8260_irq.h
msc01.h
mtd.h dm: implement a MTD uclass 2015-11-12 08:26:58 +08:00
mtd_node.h
mv88e6352.h
mvebu_mmc.h
mvmfp.h
nand.h Add more SPDX-License-Identifier tags 2016-01-19 08:31:21 -05:00
net.h Merge branch 'master' of git://git.denx.de/u-boot-net 2016-01-28 18:42:10 -05:00
netdev.h net: emaclite: Move driver to DM 2016-01-27 15:55:52 +01:00
ns16550.h Revert "dm: ns16550: Add support for reg-offset property" 2016-02-29 10:26:20 -05:00
ns87308.h
onenand_uboot.h
os.h
palmas.h
panel.h dm: panel: Add a panel uclass 2016-01-21 20:42:36 -07:00
part.h part: Drop duplication declaration of block_dev_desc_t 2016-01-25 10:39:46 -05:00
part_efi.h part:efi: add GUID for linux file system data 2015-11-12 15:58:57 -05:00
pc_keyb.h
pca953x.h Add more SPDX-License-Identifier tags 2016-01-19 08:31:21 -05:00
pca9564.h
pca9698.h
pch.h dm: pch: Add get_io_base op 2016-02-05 12:47:21 +08:00
pci.h dm: pci: Add missing forward declarations 2016-02-05 12:47:24 +08:00
pci_gt64120.h
pci_ids.h x86: pci: Add PCI IDs for Wildcat Point 2015-10-21 07:46:27 -06:00
pci_msc01.h
pci_rom.h dm: pci: video: Convert video and pci_rom to use DM PCI API 2016-01-12 10:19:09 -07:00
pcmcia.h
phy.h net: phy: introduce a quirk PHY_FLAG_BROKEN_RESET 2016-01-28 13:20:30 -06:00
phys2bus.h
physmem.h
post.h
ppc_asm.tmpl
ppc_defs.h
ps2mult.h
pwm.h dm: pwm: Add a PWM uclass 2016-01-21 20:42:36 -07:00
pwrseq.h dm: Add a power sequencing uclass 2016-01-21 20:42:34 -07:00
pxa_lcd.h
radeon.h
ram.h
rc4.h
regmap.h
reiserfs.h
remoteproc.h drivers: Introduce a simplified remoteproc framework 2015-10-22 14:18:38 -04:00
reset.h
rtc.h
rtc_def.h
s6e63d6.h
s_record.h
samsung-usb-phy-uboot.h
sandbox-adc.h sandbox: adc: Add missing header file 2015-11-05 12:58:04 +09:00
sandboxblockdev.h
sandboxfs.h
sata.h
scf0403_lcd.h
scsi.h
sdhci.h
search.h
sed156x.h
sed13806.h
serial.h serial: remove altera serial initializations 2015-10-23 07:37:03 +08:00
sh_pfc.h
sh_tmu.h
sja1000.h
slre.h
sm501.h
smsc_lpc47m.h
smsc_sio1007.h superio: Add SMSC SIO1007 driver 2016-02-21 13:42:52 +08:00
sound.h
sparse_defs.h
sparse_format.h
spartan2.h
spartan3.h
spd.h
spd_sdram.h
spi.h spi: Add support for dual and quad mode 2016-01-13 18:47:27 +05:30
spi_flash.h Add more SPDX-License-Identifier tags 2016-01-19 08:31:21 -05:00
spl.h spl: mmc: add support for BOOT_DEVICE_MMC2 2015-11-18 14:50:05 -05:00
splash.h splash_source: add support for filesystem formatted sata 2015-11-16 12:01:35 +01:00
status_led.h allow LED initialization without STATUS_LED_BOOT 2015-10-24 13:50:02 -04:00
stdio_dev.h video: Drop DEV_EXT_VIDEO flag 2015-11-05 08:24:42 +01:00
stdlib.h
stratixII.h
sx151x.h
sy8106a.h sunxi: power: add support for sy8106a driver 2016-02-23 20:50:07 +01:00
sym53c8xx.h
syscon.h dm: syscon: Allow finding devices by driver data 2016-01-24 12:07:19 +08:00
systemace.h
tca642x.h
tegra-kbc.h
thermal.h
thor.h
ti-usb-phy-uboot.h
timer.h timer: Provide an early timer 2016-02-26 08:53:10 -07:00
timestamp.h
tmu.h
tpm.h dm: tpm: Remove every compilation switch for TPM driver model 2015-10-23 09:42:28 -06:00
tps6586x.h
trace.h
tsec.h net: tsec: Use priv->tbiaddr to initialize TBI PHY address 2016-01-28 12:23:19 -06:00
tsi108.h
tsi148.h
twl4030.h
twl6030.h
tws.h
ubi_uboot.h
ubifs_uboot.h ubifs: Add functions for generic fs use 2015-10-24 13:50:32 -04:00
universe.h
usb.h usb: Allow up to 7 storage devices 2016-01-07 10:27:07 -07:00
usb_cdc_acm.h
usb_defs.h
usb_ether.h usb: eth: add Realtek RTL8152B/RTL8153 DRIVER 2016-01-23 16:22:34 +01:00
usb_mass_storage.h ums: support multiple LUNs at once 2016-01-13 21:05:19 -05:00
usbdescriptors.h
usbdevice.h
usbroothubdes.h
uuid.h uuid: add selection by string for known partition type GUID 2015-11-12 15:58:58 -05:00
vbe.h
version.h
video.h video: Correct 'tor' typo in comment 2016-01-30 10:58:47 +01:00
video_bridge.h
video_console.h video: Provide a backspace method 2016-01-30 10:55:37 +01:00
video_easylogo.h
video_fb.h
video_font.h
video_font_4x6.h
video_font_data.h
video_logo.h
virtex2.h
vsc7385.h
vsc9953.h drivers: net: vsc9953: Add LAG support 2016-01-28 12:22:19 -06:00
vsprintf.h vsprintf.c: Always enable CONFIG_SYS_VSNPRINTF 2016-01-19 08:31:16 -05:00
vxworks.h cmd: bootvx: Pass E820 information to an x86 VxWorks kernel 2015-10-21 07:46:26 -06:00
w83c553f.h
wait_bit.h lib: Add wait_for_bit 2016-01-25 10:39:47 -05:00
watchdog.h
winbond_w83627.h misc: Add simple driver to enable the legacy UART on Winbond Super IO chips 2016-01-28 13:53:30 +08:00
xilinx.h
xyzModem.h
zfs_common.h
zynqpl.h