util/: Replace GPLv2 boiler plate with SPDX header
Used commands:
perl -i -p0e 's|\/\*[\s*]*.*is free software[:;][\s*]*you[\s*]*can[\s*]*redistribute[\s*]*it[\s*]*and\/or[\s*]*modify[\s*]*it[\s*]*under[\s*]*the[\s*]*terms[\s*]*of[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*as[\s*]*published[\s*]*by[\s*]*the[\s*]*Free[\s*]*Software[\s*]*Foundation[;,][\s*]*version[\s*]*2[\s*]*of[\s*]*the[\s*]*License.[\s*]*This[\s*]*program[\s*]*is[\s*]*distributed[\s*]*in[\s*]*the[\s*]*hope[\s*]*that[\s*]*it[\s*]*will[\s*]*be[\s*]*useful,[\s*]*but[\s*]*WITHOUT[\s*]*ANY[\s*]*WARRANTY;[\s*]*without[\s*]*even[\s*]*the[\s*]*implied[\s*]*warranty[\s*]*of[\s*]*MERCHANTABILITY[\s*]*or[\s*]*FITNESS[\s*]*FOR[\s*]*A[\s*]*PARTICULAR[\s*]*PURPOSE.[\s*]*See[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*for[\s*]*more[\s*]*details.[\s*]*\*\/|/* SPDX-License-Identifier: GPL-2.0-only */|' $(cat filelist)
perl -i -p0e 's|This[\s*]*program[\s*]*is[\s*]*free[\s*]*software[:;][\s*]*you[\s*]*can[\s*]*redistribute[\s*]*it[\s*]*and/or[\s*]*modify[\s*]*it[\s*]*under[\s*]*the[\s*]*terms[\s*]*of[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*as[\s*]*published[\s*]*by[\s*]*the[\s*]*Free[\s*]*Software[\s*]*Foundation[;,][\s*]*either[\s*]*version[\s*]*2[\s*]*of[\s*]*the[\s*]*License,[\s*]*or[\s*]*.at[\s*]*your[\s*]*option.*[\s*]*any[\s*]*later[\s*]*version.[\s*]*This[\s*]*program[\s*]*is[\s*]*distributed[\s*]*in[\s*]*the[\s*]*hope[\s*]*that[\s*]*it[\s*]*will[\s*]*be[\s*]*useful,[\s*]*but[\s*]*WITHOUT[\s*]*ANY[\s*]*WARRANTY;[\s*]*without[\s*]*even[\s*]*the[\s*]*implied[\s*]*warranty[\s*]*of[\s*]*MERCHANTABILITY[\s*]*or[\s*]*FITNESS[\s*]*FOR[\s*]*A[\s*]*PARTICULAR[\s*]*PURPOSE.[\s*]*See[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*for[\s*]*more[\s*]*details.[\s*]*\*\/|/* SPDX-License-Identifier: GPL-2.0-or-later */|' $(cat filelist)
perl -i -p0e 's|\/\*[\s*]*.*This[\s*#]*program[\s*#]*is[\s*#]*free[\s*#]*software[;:,][\s*#]*you[\s*#]*can[\s*#]*redistribute[\s*#]*it[\s*#]*and/or[\s*#]*modify[\s*#]*it[\s*#]*under[\s*#]*the[\s*#]*terms[\s*#]*of[\s*#]*the[\s*#]*GNU[\s*#]*General[\s*#]*Public[\s*#]*License[\s*#]*as[\s*#]*published[\s*#]*by[\s*#]*the[\s*#]*Free[\s*#]*Software[\s*#]*Foundation[;:,][\s*#]*either[\s*#]*version[\s*#]*3[\s*#]*of[\s*#]*the[\s*#]*License[;:,][\s*#]*or[\s*#]*.at[\s*#]*your[\s*#]*option.*[\s*#]*any[\s*#]*later[\s*#]*version.[\s*#]*This[\s*#]*program[\s*#]*is[\s*#]*distributed[\s*#]*in[\s*#]*the[\s*#]*hope[\s*#]*that[\s*#]*it[\s*#]*will[\s*#]*be[\s*#]*useful[;:,][\s*#]*but[\s*#]*WITHOUT[\s*#]*ANY[\s*#]*WARRANTY[;:,][\s*#]*without[\s*#]*even[\s*#]*the[\s*#]*implied[\s*#]*warranty[\s*#]*of[\s*#]*MERCHANTABILITY[\s*#]*or[\s*#]*FITNESS[\s*#]*FOR[\s*#]*A[\s*#]*PARTICULAR[\s*#]*PURPOSE.[\s*#]*See[\s*#]*the[\s*#]*GNU[\s*#]*General[\s*#]*Public[\s*#]*License[\s*#]*for[\s*#]*more[\s*#]*details.[\s*]*\*\/|/* SPDX-License-Identifier: GPL-3.0-or-later */|' $(cat filelist)
perl -i -p0e 's|(\#\#*)[\w]*.*is free software[:;][\#\s]*you[\#\s]*can[\#\s]*redistribute[\#\s]*it[\#\s]*and\/or[\#\s]*modify[\#\s]*it[\s\#]*under[\s \#]*the[\s\#]*terms[\s\#]*of[\s\#]*the[\s\#]*GNU[\s\#]*General[\s\#]*Public[\s\#]*License[\s\#]*as[\s\#]*published[\s\#]*by[\s\#]*the[\s\#]*Free[\s\#]*Software[\s\#]*Foundation[;,][\s\#]*version[\s\#]*2[\s\#]*of[\s\#]*the[\s\#]*License.*[\s\#]*This[\s\#]*program[\s\#]*is[\s\#]*distributed[\s\#]*in[\s\#]*the[\s\#]*hope[\s\#]*that[\s\#]*it[\s\#]*will[\#\s]*be[\#\s]*useful,[\#\s]*but[\#\s]*WITHOUT[\#\s]*ANY[\#\s]*WARRANTY;[\#\s]*without[\#\s]*even[\#\s]*the[\#\s]*implied[\#\s]*warranty[\#\s]*of[\#\s]*MERCHANTABILITY[\#\s]*or[\#\s]*FITNESS[\#\s]*FOR[\#\s]*A[\#\s]*PARTICULAR[\#\s]*PURPOSE.[\#\s]*See[\#\s]*the[\#\s]*GNU[\#\s]*General[\#\s]*Public[\#\s]*License[\#\s]*for[\#\s]*more[\#\s]*details.\s(#* *\n)*|\1 SPDX-License-Identifier: GPL-2.0-only\n\n|' $(cat filelist)
perl -i -p0e 's|(\#\#*)[\w*]*.*is free software[:;][\s*]*you[\s*]*can[\s*]*redistribute[\s*]*it[\s*]*and\/or[\s*]*modify[\s*]*it[\s*]*under[\s*]*the[\s*]*terms[\s*]*of[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*as[\s*]*published[\s*]*by[\s*]*the[\s*]*Free[\s*]*Software[\s*]*Foundation[;,][\s*]*version[\s*]*2[\s*]*of[\s*]*the[\s*]*License.[\s*]*This[\s*]*program[\s*]*is[\s*]*distributed[\s*]*in[\s*]*the[\s*]*hope[\s*]*that[\s*]*it[\s*]*will[\s*]*be[\s*]*useful,[\s*]*but[\s*]*WITHOUT[\s*]*ANY[\s*]*WARRANTY;[\s*]*without[\s*]*even[\s*]*the[\s*]*implied[\s*]*warranty[\s*]*of[\s*]*MERCHANTABILITY[\s*]*or[\s*]*FITNESS[\s*]*FOR[\s*]*A[\s*]*PARTICULAR[\s*]*PURPOSE.[\s*]*See[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*for[\s*]*more[\s*]*details.\s(#* *\n)*|\1 SPDX-License-Identifier: GPL-2.0-only\n\n|' $(cat filelist)
Change-Id: I1008a63b804f355a916221ac994701d7584f60ff
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/41177
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2020-05-08 20:48:04 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2014-03-07 22:11:53 +01:00
|
|
|
|
|
|
|
#ifndef TOOL_RMODULE_H
|
|
|
|
#define TOOL_RMODULE_H
|
|
|
|
|
2015-09-09 00:24:04 +02:00
|
|
|
#include "elfparsing.h"
|
2014-03-07 22:11:53 +01:00
|
|
|
#include "common.h"
|
|
|
|
|
2015-09-09 00:24:04 +02:00
|
|
|
struct arch_ops {
|
|
|
|
int arch;
|
|
|
|
/* Determine if relocation is a valid type for the architecture. */
|
|
|
|
int (*valid_type)(Elf64_Rela *rel);
|
|
|
|
/* Determine if relocation should be emitted. */
|
|
|
|
int (*should_emit)(Elf64_Rela *rel);
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The fields in rmod_context are read-only to the user. These are
|
|
|
|
* exposed for easy shareability.
|
|
|
|
*/
|
|
|
|
struct rmod_context {
|
|
|
|
/* Ops to process relocations. */
|
|
|
|
const struct arch_ops *ops;
|
|
|
|
|
|
|
|
/* endian conversion ops */
|
|
|
|
struct xdr *xdr;
|
|
|
|
|
2018-08-23 18:08:20 +02:00
|
|
|
/* Parsed ELF structure. */
|
2015-09-09 00:24:04 +02:00
|
|
|
struct parsed_elf pelf;
|
|
|
|
/* Program segment. */
|
|
|
|
Elf64_Phdr *phdr;
|
2023-08-31 00:35:46 +02:00
|
|
|
/* Number of loadable segments. */
|
|
|
|
size_t nsegments;
|
2021-02-13 02:37:27 +01:00
|
|
|
/* Symbol string table. */
|
|
|
|
char *strtab;
|
2015-09-09 00:24:04 +02:00
|
|
|
|
|
|
|
/* Collection of relocation addresses fixup in the module. */
|
|
|
|
Elf64_Xword nrelocs;
|
|
|
|
Elf64_Addr *emitted_relocs;
|
|
|
|
|
|
|
|
/* The following fields are addresses within the linked program. */
|
|
|
|
Elf64_Addr parameters_begin;
|
|
|
|
Elf64_Addr parameters_end;
|
|
|
|
Elf64_Addr bss_begin;
|
|
|
|
Elf64_Addr bss_end;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct reloc_filter {
|
|
|
|
/* Return < 0 on error. 0 to ignore relocation and 1 to include
|
|
|
|
* relocation. */
|
|
|
|
int (*filter)(struct reloc_filter *f, const Elf64_Rela *r);
|
|
|
|
/* Pointer for filter provides */
|
|
|
|
void *context;
|
|
|
|
};
|
|
|
|
|
2014-03-07 22:11:53 +01:00
|
|
|
/*
|
|
|
|
* Parse an ELF file within the elfin buffer and fill in the elfout buffer
|
|
|
|
* with a created rmodule in ELF format. Return 0 on success, < 0 on error.
|
|
|
|
*/
|
|
|
|
int rmodule_create(const struct buffer *elfin, struct buffer *elfout);
|
|
|
|
|
2015-09-09 00:24:04 +02:00
|
|
|
/*
|
|
|
|
* Initialize an rmodule context from an ELF buffer. Returns 0 on scucess, < 0
|
|
|
|
* on error.
|
|
|
|
*/
|
|
|
|
int rmodule_init(struct rmod_context *ctx, const struct buffer *elfin);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Collect all the relocations that apply to the program in
|
|
|
|
* nrelocs/emitted_relocs. One can optionally provide a reloc_filter object
|
|
|
|
* to help in relocation filtering. The filter function will be called twice:
|
|
|
|
* once for counting and once for emitting. The same response should be
|
|
|
|
* provided for each call. Returns 0 on success, < 0 on error.
|
|
|
|
*/
|
|
|
|
int rmodule_collect_relocations(struct rmod_context *c, struct reloc_filter *f);
|
|
|
|
|
2018-11-22 14:21:12 +01:00
|
|
|
/* Clean up the memory consumed by the rmodule context. */
|
2015-09-09 00:24:04 +02:00
|
|
|
void rmodule_cleanup(struct rmod_context *ctx);
|
|
|
|
|
2015-10-28 17:39:34 +01:00
|
|
|
/*
|
|
|
|
* Create an ELF file from the passed in rmodule in the buffer. The buffer
|
|
|
|
* contents will be replaced with an ELF file. Returns 1 if buff doesn't
|
|
|
|
* contain an rmodule and < 0 on failure, 0 on success.
|
|
|
|
*/
|
|
|
|
int rmodule_stage_to_elf(Elf64_Ehdr *ehdr, struct buffer *buff);
|
|
|
|
|
2014-03-07 22:11:53 +01:00
|
|
|
#endif /* TOOL_RMODULE_H */
|