Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update smartelf2hex to use MemSiz instead of FileSiz #693

Merged
merged 1 commit into from
Oct 19, 2020

Conversation

jerryz123
Copy link
Contributor

@jerryz123 jerryz123 commented Oct 13, 2020

elf2hex writes zeros to a segment for which MemSize > FileSize, which adheres to the ELF spec.
Thus, we should calculate the total size of the file from the MemSize of the last segment, rather than the FileSize.

From man elf:

                        The array element specifies a loadable segment,
                        described by p_filesz and p_memsz.  The bytes from
                        the file are mapped to the beginning of the memory
                        segment.  If the segment's memory size p_memsz is
                        larger than the file size p_filesz, the "extra"
                        bytes are defined to hold the value 0 and to follow
                        the segment's initialized area.  The file size may
                        not be larger than the memory size.  Loadable seg‐
                        ment entries in the program header table appear in
                        ascending order, sorted on the p_vaddr member.

Related issue:

Type of change: bug fix

Impact: software change

Release Notes

elf2hex writes zeros to a segment for which MemSize > FileSize, which adheres to the ELF spec.
Thus, we should calculate the total size of the file from the MemSize of the last segment, rather than the FileSize.
Copy link
Contributor

@colinschmidt colinschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jerryz123 jerryz123 merged commit 11fdf69 into dev Oct 19, 2020
@alonamid alonamid mentioned this pull request Nov 24, 2020
@jerryz123 jerryz123 deleted the smartelf2hex-memsiz branch December 24, 2020 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants