* [PATCH] common: elf: rename elf_section misnomer to elf_segment
@ 2025-11-03 7:45 Ahmad Fatoum
2025-11-03 8:42 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2025-11-03 7:45 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
An elf section is needed for linking, the segment is needed for loading.
We only handle statically linked ELF files currently in barebox, so we
do not look at the sections at all.
Replace the misleading struct elf_section with the correct naming:
elf_segment.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
common/elf.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/common/elf.c b/common/elf.c
index 8578892366c3..c68ea0be3fa6 100644
--- a/common/elf.c
+++ b/common/elf.c
@@ -14,7 +14,7 @@
#include <linux/fs.h>
#include <linux/list_sort.h>
-struct elf_section {
+struct elf_segment {
struct list_head list;
struct resource *r;
void *phdr;
@@ -26,16 +26,16 @@ static int elf_request_region(struct elf_image *elf, resource_size_t start,
{
struct list_head *list = &elf->list;
struct resource *r_new;
- struct elf_section *r;
+ struct elf_segment *r;
r = calloc(1, sizeof(*r));
if (!r)
return -ENOMEM;
- r_new = request_sdram_region("elf_section", start, size,
+ r_new = request_sdram_region("elf_segment", start, size,
MEMTYPE_LOADER_CODE, MEMATTRS_RWX);
if (!r_new) {
- r_new = request_iomem_region("elf_section", start, size);
+ r_new = request_iomem_region("elf_segment", start, size);
if (!r_new) {
pr_err("Failed to request region: %pa %pa\n", &start, &size);
return -EINVAL;
@@ -53,7 +53,7 @@ static int elf_request_region(struct elf_image *elf, resource_size_t start,
static void elf_release_regions(struct elf_image *elf)
{
struct list_head *list = &elf->list;
- struct elf_section *r, *r_tmp;
+ struct elf_segment *r, *r_tmp;
list_for_each_entry_safe(r, r_tmp, list, list) {
if (r->is_iomem_region)
@@ -92,16 +92,16 @@ static int request_elf_segment(struct elf_image *elf, void *phdr)
return 0;
}
-static int elf_section_cmp(void *priv, struct list_head *a, struct list_head *b)
+static int elf_segment_cmp(void *priv, struct list_head *a, struct list_head *b)
{
struct elf_image *elf = priv;
- struct elf_section *elf_a, *elf_b;
+ struct elf_segment *elf_a, *elf_b;
if (a == b)
return 0;
- elf_a = list_entry(a, struct elf_section, list);
- elf_b = list_entry(b, struct elf_section, list);
+ elf_a = list_entry(a, struct elf_segment, list);
+ elf_b = list_entry(b, struct elf_segment, list);
return elf_phdr_p_offset(elf, elf_a->phdr) >
elf_phdr_p_offset(elf, elf_b->phdr);
@@ -112,7 +112,7 @@ static int load_elf_to_memory(struct elf_image *elf)
void *dst;
int ret = 0, fd = -1;
u64 p_filesz, p_memsz, p_offset;
- struct elf_section *r;
+ struct elf_segment *r;
struct list_head *list = &elf->list;
if (elf->filename) {
@@ -185,7 +185,7 @@ static int load_elf_image_segments(struct elf_image *elf)
* Sort the list to avoid doing backward lseek while loading the elf
* segments from file to memory(some filesystems don't support it)
*/
- list_sort(elf, &elf->list, elf_section_cmp);
+ list_sort(elf, &elf->list, elf_segment_cmp);
ret = load_elf_to_memory(elf);
if (ret)
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] common: elf: rename elf_section misnomer to elf_segment
2025-11-03 7:45 [PATCH] common: elf: rename elf_section misnomer to elf_segment Ahmad Fatoum
@ 2025-11-03 8:42 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2025-11-03 8:42 UTC (permalink / raw)
To: barebox, Ahmad Fatoum
On Mon, 03 Nov 2025 08:45:08 +0100, Ahmad Fatoum wrote:
> An elf section is needed for linking, the segment is needed for loading.
>
> We only handle statically linked ELF files currently in barebox, so we
> do not look at the sections at all.
>
> Replace the misleading struct elf_section with the correct naming:
> elf_segment.
>
> [...]
Applied, thanks!
[1/1] common: elf: rename elf_section misnomer to elf_segment
https://git.pengutronix.de/cgit/barebox/commit/?id=ea3dc64d3218 (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-11-03 8:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-03 7:45 [PATCH] common: elf: rename elf_section misnomer to elf_segment Ahmad Fatoum
2025-11-03 8:42 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox