From 038129b11ac71a13ccaf9029122be86d6c532990 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sun, 4 Dec 2005 16:47:24 +0000 Subject: [PATCH] More relaxation for unloaded reloc sections. --- src/ChangeLog | 6 ++++++ src/elflint.c | 50 +++++++++++++++++++++++++++----------------------- 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 4c668c231..e03f056d2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2005-12-04 Ulrich Drepper + + * elflint.c (check_one_reloc): If relocation section is not loaded, + don't check whether the relocations modify read-only sections or + loaded and unloaded sections. + 2005-11-28 Ulrich Drepper * elflint.c (check_one_reloc): Take additional parameters. Use diff --git a/src/elflint.c b/src/elflint.c index 227a463cd..32d52976a 100644 --- a/src/elflint.c +++ b/src/elflint.c @@ -1205,37 +1205,41 @@ section [%2d] '%s': relocation %zu: offset out of bounds\n"), buf, sizeof (buf))); } - bool in_loaded_seg = false; - while (loaded != NULL) + if ((ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN) + || (relshdr->sh_flags & SHF_ALLOC) != 0) { - if (r_offset < loaded->to - && r_offset + (sym == NULL ? 0 : sym->st_size) >= loaded->from) + bool in_loaded_seg = false; + while (loaded != NULL) { - /* The symbol is in this segment. */ - if (loaded->read_only) + if (r_offset < loaded->to + && r_offset + (sym == NULL ? 0 : sym->st_size) >= loaded->from) { - if (textrel) - needed_textrel = true; - else - ERROR (gettext ("section [%2d] '%s': relocation %zu: read-only section modified but text relocation flag not set\n"), - idx, section_name (ebl, idx), cnt); + /* The symbol is in this segment. */ + if (loaded->read_only) + { + if (textrel) + needed_textrel = true; + else + ERROR (gettext ("section [%2d] '%s': relocation %zu: read-only section modified but text relocation flag not set\n"), + idx, section_name (ebl, idx), cnt); + } + + in_loaded_seg = true; } - in_loaded_seg = true; + loaded = loaded->next; } - loaded = loaded->next; - } - - if (*statep == state_undecided) - *statep = in_loaded_seg ? state_loaded : state_unloaded; - else if ((*statep == state_unloaded && in_loaded_seg) - || (*statep == state_loaded && !in_loaded_seg)) - { - ERROR (gettext ("\ + if (*statep == state_undecided) + *statep = in_loaded_seg ? state_loaded : state_unloaded; + else if ((*statep == state_unloaded && in_loaded_seg) + || (*statep == state_loaded && !in_loaded_seg)) + { + ERROR (gettext ("\ section [%2d] '%s': relocations are against loaded and unloaded data\n"), - idx, section_name (ebl, idx)); - *statep = state_error; + idx, section_name (ebl, idx)); + *statep = state_error; + } } } -- 2.47.2