Closed scottconstable closed 2 years ago
Resizing an existing allocatable section in-place is not currently possible. You can allocate a new section, e.g. .rodata
and place new contents in there. This new section will be allocated in a newly created segment. The old section will be renamed .bolt.org.rodata
. E.g., this is something BOLT does under -jump-tables=move
option where new jump tables are being placed in .rodata
.
Hi, thanks for the prompt response. I now see that I can effectively create a new rodata section with the BinaryContext::registerOrUpdateSection
API. Thanks!
I am trying to figure out how to expand the .rodata section from by
BinaryFunctionPass
. I can get the section and confirm that its size matches what I see inobjdump
, but then when I try toaddPatch
some bytes I do not observe any change in the output binary. Looking through the BOLT source code, I see some examples inRewriteInstance.cpp
that appear to patch some data sections, but it isn't clear to me how these patches materialize in the final binary. Is there a convenient way to resize a data section from aBinaryFunctionPass
?Here is my experimental code: