[PATCH 1/2] readelf: Warn if PT_DYNAMIC segment doesn't match .dynamic section
H.J. Lu
hjl.tools@gmail.com
Tue Apr 14 13:28:55 GMT 2020
The PT_DYNAMIC segment, which is used by the run-time loader, must
exactly match the .dynamic section.
PR binutils/25809
* readelf.c (process_program_headers): Warn if the PT_DYNAMIC
segment doesn't match the .dynamic section.
---
binutils/readelf.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 535d47a58e..91e47887e7 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -5337,13 +5337,12 @@ process_program_headers (Filedata * filedata)
dynamic_addr = sec->sh_offset;
dynamic_size = sec->sh_size;
- if (dynamic_addr < segment->p_offset
- || dynamic_addr > segment->p_offset + segment->p_filesz)
- warn (_("the .dynamic section is not contained"
- " within the dynamic segment\n"));
- else if (dynamic_addr > segment->p_offset)
- warn (_("the .dynamic section is not the first section"
- " in the dynamic segment.\n"));
+ /* The PT_DYNAMIC segment, which is used by the run-time
+ loader, must exactly match the .dynamic section. */
+ if (dynamic_addr != segment->p_offset
+ || dynamic_size != segment->p_filesz)
+ warn (_("the .dynamic section doesn't match the "
+ "dynamic segment\n"));
}
/* PR binutils/17512: Avoid corrupt dynamic section info in the
--
2.25.2
More information about the Binutils
mailing list