Closed getianao closed 2 years ago
Hi @getianao, for x86 minimum page size is 4K, it's not possible to use less
Thanks for your reply. Seems a LOAD segment with an alignment less than 4K will make program crash becouse of x86 minimum page size. I modify the Phdr table and avoid adding new allocatable sections at the end of program, then the program works well.
Now I'm curious why BOLT choosing to place sections at the end of the binary, rather than the original place and modify the offsets of other sections. Because the former will leave lots of useless empty space and make binary larger.
@getianao one of the reason is described as comment https://github.com/facebookincubator/BOLT/blob/main/bolt/lib/Rewrite/RewriteInstance.cpp#L506
@getianao what sections are you talking about?
@yavtuk I notice .eh_frame_hdr
and .eh_frame
sections are added at the end. Also I want to know why not changing the offset when new .text
section larger than the old .text
section.
.cfi_startproc is used at the beginning of each function that should have an entry in .eh_frame. As we move new “.text” section to new segment due to larger size we also couldn’t use the old sections eh_frame & eh_frane_hdr and we should create new one with new size, but I am not sure actually
Thanks, it makes sense though.
Hi, I try to modify the alignment of the available address for new allocatable sections. An alignment less than 0x1000 will cause the program crash. Is it possible to set
BC->PageAlign
to a value less than 0x1000? Thanks a lot :) https://github.com/facebookincubator/BOLT/blob/61a2062542cd7f015cde0e0ff06abe305993943d/bolt/lib/Rewrite/RewriteInstance.cpp#L503