I’m curious about how does a linker link segments with same type but different flags from different object files. E.g. we now have two ELF object files foo.o and bar.o, both of which have a .text segment (code segment). However, .text segment in foo.o is write-able while that in bar.o is not. In this case, how will the linker link these two segments? How will the linker set the flag of the .text segment in the linked file?
Thanks and Best regards!
There is no
.textsegment in the linked file: the.textsection is put into one of theLOADsegments.The linker can choose what to do.
.textsections with different flags, and put them into multipleLOADsegments..textsections fromfoo.oandbar.ointo a single.textsection, and make it writable