Skip to content

Commit 5eb8787

Browse files
committed
llext: Use clang format on all llext files
If we stick with clang-format we don't need to nitpick over little spacing issues for new contributions, we can simply ask people to run the formatting tool. Much simpler. Signed-off-by: Tom Burdick <[email protected]>
1 parent e84c485 commit 5eb8787

File tree

13 files changed

+218
-267
lines changed

13 files changed

+218
-267
lines changed

include/zephyr/llext/buf_loader.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ void *llext_buf_peek(struct llext_loader *ldr, size_t pos);
7373
* @param _buf Buffer containing the ELF binary
7474
* @param _buf_len Buffer length in bytes
7575
*/
76-
#define LLEXT_BUF_LOADER(_buf, _buf_len) \
76+
#define LLEXT_BUF_LOADER(_buf, _buf_len) \
7777
Z_LLEXT_BUF_LOADER(_buf, _buf_len, \
78-
IS_ENABLED(CONFIG_LLEXT_STORAGE_WRITABLE) ? \
79-
LLEXT_STORAGE_WRITABLE : LLEXT_STORAGE_PERSISTENT)
78+
IS_ENABLED(CONFIG_LLEXT_STORAGE_WRITABLE) ? LLEXT_STORAGE_WRITABLE \
79+
: LLEXT_STORAGE_PERSISTENT)
8080

8181
/* @brief Initialize an llext_buf_loader structure for a temporary buffer
8282
*
@@ -87,7 +87,7 @@ void *llext_buf_peek(struct llext_loader *ldr, size_t pos);
8787
* @param _buf Buffer containing the ELF binary
8888
* @param _buf_len Buffer length in bytes
8989
*/
90-
#define LLEXT_TEMPORARY_BUF_LOADER(_buf, _buf_len) \
90+
#define LLEXT_TEMPORARY_BUF_LOADER(_buf, _buf_len) \
9191
Z_LLEXT_BUF_LOADER(_buf, _buf_len, LLEXT_STORAGE_TEMPORARY)
9292

9393
/**
@@ -100,7 +100,7 @@ void *llext_buf_peek(struct llext_loader *ldr, size_t pos);
100100
* @param _buf Buffer containing the ELF binary
101101
* @param _buf_len Buffer length in bytes
102102
*/
103-
#define LLEXT_PERSISTENT_BUF_LOADER(_buf, _buf_len) \
103+
#define LLEXT_PERSISTENT_BUF_LOADER(_buf, _buf_len) \
104104
Z_LLEXT_BUF_LOADER(_buf, _buf_len, LLEXT_STORAGE_PERSISTENT)
105105

106106
/**
@@ -113,7 +113,7 @@ void *llext_buf_peek(struct llext_loader *ldr, size_t pos);
113113
* @param _buf Buffer containing the ELF binary
114114
* @param _buf_len Buffer length in bytes
115115
*/
116-
#define LLEXT_WRITABLE_BUF_LOADER(_buf, _buf_len) \
116+
#define LLEXT_WRITABLE_BUF_LOADER(_buf, _buf_len) \
117117
Z_LLEXT_BUF_LOADER(_buf, _buf_len, LLEXT_STORAGE_WRITABLE)
118118

119119
/**

include/zephyr/llext/elf.h

Lines changed: 66 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ typedef int64_t elf64_sxword;
5151
/** Unsigned long integer */
5252
typedef uint64_t elf64_xword;
5353

54-
5554
/**
5655
* @brief ELF identifier block
5756
*
@@ -134,13 +133,13 @@ struct elf64_ehdr {
134133
};
135134

136135
/** Relocatable (unlinked) ELF */
137-
#define ET_REL 1
136+
#define ET_REL 1
138137

139138
/** Executable (without PIC/PIE) ELF */
140139
#define ET_EXEC 2
141140

142141
/** Dynamic (executable with PIC/PIE or shared lib) ELF */
143-
#define ET_DYN 3
142+
#define ET_DYN 3
144143

145144
/** Core Dump */
146145
#define ET_CORE 4
@@ -198,26 +197,26 @@ struct elf64_shdr {
198197
};
199198

200199
/** ELF section types */
201-
#define SHT_NULL 0x0 /**< Unused section */
202-
#define SHT_PROGBITS 0x1 /**< Program data */
203-
#define SHT_SYMTAB 0x2 /**< Symbol table */
204-
#define SHT_STRTAB 0x3 /**< String table */
205-
#define SHT_RELA 0x4 /**< Relocation entries with addends */
206-
#define SHT_NOBITS 0x8 /**< Program data with no file image */
207-
#define SHT_REL 0x9 /**< Relocation entries without addends */
208-
#define SHT_DYNSYM 0xB /**< Dynamic linking symbol table */
209-
#define SHT_INIT_ARRAY 0xe /**< Array of pointers to init functions */
210-
#define SHT_FINI_ARRAY 0xf /**< Array of pointers to termination functions */
211-
#define SHT_PREINIT_ARRAY 0x10 /**< Array of pointers to early init functions */
200+
#define SHT_NULL 0x0 /**< Unused section */
201+
#define SHT_PROGBITS 0x1 /**< Program data */
202+
#define SHT_SYMTAB 0x2 /**< Symbol table */
203+
#define SHT_STRTAB 0x3 /**< String table */
204+
#define SHT_RELA 0x4 /**< Relocation entries with addends */
205+
#define SHT_NOBITS 0x8 /**< Program data with no file image */
206+
#define SHT_REL 0x9 /**< Relocation entries without addends */
207+
#define SHT_DYNSYM 0xB /**< Dynamic linking symbol table */
208+
#define SHT_INIT_ARRAY 0xe /**< Array of pointers to init functions */
209+
#define SHT_FINI_ARRAY 0xf /**< Array of pointers to termination functions */
210+
#define SHT_PREINIT_ARRAY 0x10 /**< Array of pointers to early init functions */
212211

213212
/** ELF section flags */
214-
#define SHF_WRITE 0x1 /**< Section is writable */
215-
#define SHF_ALLOC 0x2 /**< Section is present in memory */
216-
#define SHF_EXECINSTR 0x4 /**< Section contains executable instructions */
217-
#define SHF_MASKOS 0x0ff00000 /**< OS specific flags */
213+
#define SHF_WRITE 0x1 /**< Section is writable */
214+
#define SHF_ALLOC 0x2 /**< Section is present in memory */
215+
#define SHF_EXECINSTR 0x4 /**< Section contains executable instructions */
216+
#define SHF_MASKOS 0x0ff00000 /**< OS specific flags */
218217
#define SHF_LLEXT_HAS_RELOCS 0x00100000 /**< Section is a target for relocations */
219218

220-
#define SHF_BASIC_TYPE_MASK (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR)
219+
#define SHF_BASIC_TYPE_MASK (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR)
221220

222221
/**
223222
* @brief Symbol table entry(32-bit)
@@ -256,32 +255,32 @@ struct elf64_sym {
256255
};
257256

258257
/** ELF section numbers */
259-
#define SHN_UNDEF 0 /**< Undefined section */
260-
#define SHN_LORESERVE 0xff00 /**< Start of reserved section numbers */
261-
#define SHN_ABS 0xfff1 /**< Special value for absolute symbols */
262-
#define SHN_COMMON 0xfff2 /**< Common block */
263-
#define SHN_HIRESERVE 0xffff /**< End of reserved section numbers */
258+
#define SHN_UNDEF 0 /**< Undefined section */
259+
#define SHN_LORESERVE 0xff00 /**< Start of reserved section numbers */
260+
#define SHN_ABS 0xfff1 /**< Special value for absolute symbols */
261+
#define SHN_COMMON 0xfff2 /**< Common block */
262+
#define SHN_HIRESERVE 0xffff /**< End of reserved section numbers */
264263

265264
/** Symbol table entry types */
266-
#define STT_NOTYPE 0 /**< No type */
267-
#define STT_OBJECT 1 /**< Data or object */
268-
#define STT_FUNC 2 /**< Function */
269-
#define STT_SECTION 3 /**< Section */
270-
#define STT_FILE 4 /**< File name */
271-
#define STT_COMMON 5 /**< Common block */
272-
#define STT_LOOS 10 /**< Start of OS specific */
273-
#define STT_HIOS 12 /**< End of OS specific */
274-
#define STT_LOPROC 13 /**< Start of processor specific */
275-
#define STT_HIPROC 15 /**< End of processor specific */
265+
#define STT_NOTYPE 0 /**< No type */
266+
#define STT_OBJECT 1 /**< Data or object */
267+
#define STT_FUNC 2 /**< Function */
268+
#define STT_SECTION 3 /**< Section */
269+
#define STT_FILE 4 /**< File name */
270+
#define STT_COMMON 5 /**< Common block */
271+
#define STT_LOOS 10 /**< Start of OS specific */
272+
#define STT_HIOS 12 /**< End of OS specific */
273+
#define STT_LOPROC 13 /**< Start of processor specific */
274+
#define STT_HIPROC 15 /**< End of processor specific */
276275

277276
/** Symbol table entry bindings */
278-
#define STB_LOCAL 0 /**< Local symbol */
279-
#define STB_GLOBAL 1 /**< Global symbol */
280-
#define STB_WEAK 2 /**< Weak symbol */
281-
#define STB_LOOS 10 /**< Start of OS specific */
282-
#define STB_HIOS 12 /**< End of OS specific */
283-
#define STB_LOPROC 13 /**< Start of processor specific */
284-
#define STB_HIPROC 15 /**< End of processor specific */
277+
#define STB_LOCAL 0 /**< Local symbol */
278+
#define STB_GLOBAL 1 /**< Global symbol */
279+
#define STB_WEAK 2 /**< Weak symbol */
280+
#define STB_LOOS 10 /**< Start of OS specific */
281+
#define STB_HIOS 12 /**< End of OS specific */
282+
#define STB_LOPROC 13 /**< Start of processor specific */
283+
#define STB_HIPROC 15 /**< End of processor specific */
285284

286285
/**
287286
* @brief Symbol binding from 32bit st_info
@@ -304,7 +303,6 @@ struct elf64_sym {
304303
*/
305304
#define ELF64_ST_BIND(i) ((i) >> 4)
306305

307-
308306
/**
309307
* @brief Symbol type from 32bit st_info
310308
*
@@ -404,28 +402,28 @@ struct elf64_rela {
404402
* @brief Program header(32-bit)
405403
*/
406404
struct elf32_phdr {
407-
elf32_word p_type; /**< Type of segment */
408-
elf32_off p_offset; /**< Offset in file */
409-
elf32_addr p_vaddr; /**< Virtual address in memory */
410-
elf32_addr p_paddr; /**< Physical address (usually reserved) */
411-
elf32_word p_filesz; /**< Size of segment in file */
412-
elf32_word p_memsz; /**< Size of segment in memory */
413-
elf32_word p_flags; /**< Segment flags */
414-
elf32_word p_align; /**< Alignment of segment */
405+
elf32_word p_type; /**< Type of segment */
406+
elf32_off p_offset; /**< Offset in file */
407+
elf32_addr p_vaddr; /**< Virtual address in memory */
408+
elf32_addr p_paddr; /**< Physical address (usually reserved) */
409+
elf32_word p_filesz; /**< Size of segment in file */
410+
elf32_word p_memsz; /**< Size of segment in memory */
411+
elf32_word p_flags; /**< Segment flags */
412+
elf32_word p_align; /**< Alignment of segment */
415413
};
416414

417415
/**
418416
* @brief Program header(64-bit)
419417
*/
420418
struct elf64_phdr {
421-
elf64_word p_type; /**< Type of segment */
422-
elf64_off p_offset; /**< Offset in file */
423-
elf64_addr p_vaddr; /**< Virtual address in memory */
424-
elf64_addr p_paddr; /**< Physical address (usually reserved) */
425-
elf64_xword p_filesz; /**< Size of segment in file */
426-
elf64_xword p_memsz; /**< Size of segment in memory */
427-
elf64_word p_flags; /**< Segment flags */
428-
elf64_xword p_align; /**< Alignment of segment */
419+
elf64_word p_type; /**< Type of segment */
420+
elf64_off p_offset; /**< Offset in file */
421+
elf64_addr p_vaddr; /**< Virtual address in memory */
422+
elf64_addr p_paddr; /**< Physical address (usually reserved) */
423+
elf64_xword p_filesz; /**< Size of segment in file */
424+
elf64_xword p_memsz; /**< Size of segment in memory */
425+
elf64_word p_flags; /**< Segment flags */
426+
elf64_xword p_align; /**< Alignment of segment */
429427
};
430428

431429
/**
@@ -437,21 +435,21 @@ struct elf64_phdr {
437435
* @brief Dynamic section entry(32-bit)
438436
*/
439437
struct elf32_dyn {
440-
elf32_sword d_tag; /**< Entry tag */
438+
elf32_sword d_tag; /**< Entry tag */
441439
union {
442-
elf32_word d_val; /**< Integer value */
443-
elf32_addr d_ptr; /**< Address value */
440+
elf32_word d_val; /**< Integer value */
441+
elf32_addr d_ptr; /**< Address value */
444442
} d_un;
445443
};
446444

447445
/**
448446
* @brief Dynamic section entry(64-bit)
449447
*/
450448
struct elf64_dyn {
451-
elf64_sxword d_tag; /**< Entry tag */
449+
elf64_sxword d_tag; /**< Entry tag */
452450
union {
453-
elf64_xword d_val; /**< Integer value */
454-
elf64_addr d_ptr; /**< Address value */
451+
elf64_xword d_val; /**< Integer value */
452+
elf64_addr d_ptr; /**< Address value */
455453
} d_un;
456454
};
457455
/** @endcond */
@@ -476,9 +474,9 @@ typedef struct elf64_rela elf_rela_t;
476474
/** Machine sized symbol struct */
477475
typedef struct elf64_sym elf_sym_t;
478476
/** Machine sized macro alias for obtaining a relocation symbol */
479-
#define ELF_R_SYM ELF64_R_SYM
477+
#define ELF_R_SYM ELF64_R_SYM
480478
/** Machine sized macro alias for obtaining a relocation type */
481-
#define ELF_R_TYPE ELF64_R_TYPE
479+
#define ELF_R_TYPE ELF64_R_TYPE
482480
/** Machine sized macro alias for obtaining a symbol bind */
483481
#define ELF_ST_BIND ELF64_ST_BIND
484482
/** Machine sized macro alias for obtaining a symbol type */
@@ -503,9 +501,9 @@ typedef struct elf32_rela elf_rela_t;
503501
/** Machine sized symbol struct */
504502
typedef struct elf32_sym elf_sym_t;
505503
/** Machine sized macro alias for obtaining a relocation symbol */
506-
#define ELF_R_SYM ELF32_R_SYM
504+
#define ELF_R_SYM ELF32_R_SYM
507505
/** Machine sized macro alias for obtaining a relocation type */
508-
#define ELF_R_TYPE ELF32_R_TYPE
506+
#define ELF_R_TYPE ELF32_R_TYPE
509507
/** Machine sized macro alias for obtaining a symbol bind */
510508
#define ELF_ST_BIND ELF32_ST_BIND
511509
/** Machine sized macro alias for obtaining a symbol type */

include/zephyr/llext/inspect.h

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,8 @@ extern "C" {
4545
*
4646
* @return 0 on success, -EINVAL if the region is invalid
4747
*/
48-
static inline int llext_get_region_info(const struct llext_loader *ldr,
49-
const struct llext *ext,
50-
enum llext_mem region,
51-
const elf_shdr_t **hdr,
48+
static inline int llext_get_region_info(const struct llext_loader *ldr, const struct llext *ext,
49+
enum llext_mem region, const elf_shdr_t **hdr,
5250
const void **addr, size_t *size)
5351
{
5452
if ((unsigned int)region >= LLEXT_MEM_COUNT) {
@@ -84,7 +82,7 @@ static inline int llext_get_region_info(const struct llext_loader *ldr,
8482
* -ENOTSUP if section data is not available.
8583
*/
8684
int llext_section_shndx(const struct llext_loader *ldr, const struct llext *ext,
87-
const char *section_name);
85+
const char *section_name);
8886

8987
/**
9088
* @brief Get information about a section for the specified extension.
@@ -105,12 +103,9 @@ int llext_section_shndx(const struct llext_loader *ldr, const struct llext *ext,
105103
* @return 0 on success, -EINVAL if the section index is invalid,
106104
* -ENOTSUP if section data is not available.
107105
*/
108-
static inline int llext_get_section_info(const struct llext_loader *ldr,
109-
const struct llext *ext,
110-
unsigned int shndx,
111-
const elf_shdr_t **hdr,
112-
enum llext_mem *region,
113-
size_t *offset)
106+
static inline int llext_get_section_info(const struct llext_loader *ldr, const struct llext *ext,
107+
unsigned int shndx, const elf_shdr_t **hdr,
108+
enum llext_mem *region, size_t *offset)
114109
{
115110
if (shndx < 0 || shndx >= ext->sect_cnt) {
116111
return -EINVAL;

include/zephyr/llext/llext.h

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,25 @@ extern "C" {
4242
* together into a single memory region.
4343
*/
4444
enum llext_mem {
45-
LLEXT_MEM_TEXT, /**< Executable code */
46-
LLEXT_MEM_DATA, /**< Initialized data */
47-
LLEXT_MEM_RODATA, /**< Read-only data */
48-
LLEXT_MEM_BSS, /**< Uninitialized data */
49-
LLEXT_MEM_EXPORT, /**< Exported symbol table */
50-
LLEXT_MEM_SYMTAB, /**< Symbol table */
51-
LLEXT_MEM_STRTAB, /**< Symbol name strings */
52-
LLEXT_MEM_SHSTRTAB, /**< Section name strings */
53-
LLEXT_MEM_PREINIT, /**< Array of early setup functions */
54-
LLEXT_MEM_INIT, /**< Array of setup functions */
55-
LLEXT_MEM_FINI, /**< Array of cleanup functions */
56-
57-
LLEXT_MEM_COUNT, /**< Number of regions managed by LLEXT */
45+
LLEXT_MEM_TEXT, /**< Executable code */
46+
LLEXT_MEM_DATA, /**< Initialized data */
47+
LLEXT_MEM_RODATA, /**< Read-only data */
48+
LLEXT_MEM_BSS, /**< Uninitialized data */
49+
LLEXT_MEM_EXPORT, /**< Exported symbol table */
50+
LLEXT_MEM_SYMTAB, /**< Symbol table */
51+
LLEXT_MEM_STRTAB, /**< Symbol name strings */
52+
LLEXT_MEM_SHSTRTAB, /**< Section name strings */
53+
LLEXT_MEM_PREINIT, /**< Array of early setup functions */
54+
LLEXT_MEM_INIT, /**< Array of setup functions */
55+
LLEXT_MEM_FINI, /**< Array of cleanup functions */
56+
57+
LLEXT_MEM_COUNT, /**< Number of regions managed by LLEXT */
5858
};
5959

6060
/** @cond ignore */
6161

6262
/* Number of memory partitions used by LLEXT */
63-
#define LLEXT_MEM_PARTITIONS (LLEXT_MEM_BSS+1)
63+
#define LLEXT_MEM_PARTITIONS (LLEXT_MEM_BSS + 1)
6464

6565
struct llext_loader;
6666
/** @endcond */
@@ -178,7 +178,10 @@ struct llext_load_param {
178178
};
179179

180180
/** Default initializer for @ref llext_load_param */
181-
#define LLEXT_LOAD_PARAM_DEFAULT { .relocate_local = true, }
181+
#define LLEXT_LOAD_PARAM_DEFAULT \
182+
{ \
183+
.relocate_local = true, \
184+
}
182185

183186
/**
184187
* @brief Find an llext by name

0 commit comments

Comments
 (0)