defaultenv: Align defaultenv array
The default environment buffer is an unsigned char array and thus may be unaligned. Some decompression algorithms expect the buffer to be sufficiently aligned for u32 accesses. We make this sure by copying the default env to a temporary buffer. Instead of doing this just add a __aligned(4) to the default environment. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
0a2a8f7059
commit
5d22cb3856
|
@ -77,7 +77,7 @@ $(obj)/barebox_default_env: FORCE
|
|||
$(call cmd,envs)
|
||||
|
||||
quiet_cmd_env_h = ENVH $@
|
||||
cmd_env_h = cat $< | (cd $(obj) && $(objtree)/scripts/bin2c default_environment) > $@; \
|
||||
cmd_env_h = cat $< | (cd $(obj) && $(objtree)/scripts/bin2c "__aligned(4) default_environment") > $@; \
|
||||
echo "static const int default_environment_uncompress_size=`stat -c%s $(obj)/barebox_default_env`;" >> $@
|
||||
|
||||
$(obj)/barebox_default_env.h: $(obj)/barebox_default_env$(DEFAULT_COMPRESSION_SUFFIX) FORCE
|
||||
|
|
|
@ -53,21 +53,12 @@ static int register_default_env(void)
|
|||
void *defaultenv;
|
||||
|
||||
if (!IS_ENABLED(CONFIG_DEFAULT_COMPRESSION_NONE)) {
|
||||
void *tmp = malloc(default_environment_size);
|
||||
|
||||
if (!tmp)
|
||||
return -ENOMEM;
|
||||
|
||||
memcpy(tmp, default_environment, default_environment_size);
|
||||
|
||||
defaultenv = xzalloc(default_environment_uncompress_size);
|
||||
|
||||
ret = uncompress(tmp, default_environment_size,
|
||||
ret = uncompress(default_environment, default_environment_size,
|
||||
NULL, NULL,
|
||||
defaultenv, NULL, uncompress_err_stdout);
|
||||
|
||||
free(tmp);
|
||||
|
||||
if (ret) {
|
||||
free(defaultenv);
|
||||
return ret;
|
||||
|
|
Loading…
Reference in New Issue