{"push_id":3837959152,"size":1,"distinct_size":1,"ref":"refs/heads/align","head":"4e53e7290a19dffe181bce1bce58727023b98ea8","before":"b3afd236eeda5610818b5685e5cdf7b2cacad546","commits":[{"sha":"4e53e7290a19dffe181bce1bce58727023b98ea8","author":{"name":"Fangrui Song","email":"042dc4512fa3d391c5170cf3aa61e6a638f84342@maskray.me"},"message":"[ELF][PPC] Allow PT_LOAD to have overlapping p_offset ranges\n\nSummary:\nThis change affects the non-linker script case (precisely, when the\n`SECTIONS` command is not used). Let me demonstrate the idea with a\nmaxPageSize=65536 example:\n\nWhen assigning the address to the first output section of a new PT_LOAD,\nif the end position of last section of the previous PT_LOAD is 0x10020,\nwe advance to the next multiple of maxPageSize: 0x20000. The new PT_LOAD\nwill thus have p_vaddr=0x20000. Because p_offset and p_vaddr are\ncongruent modulo maxPageSize, p_offset will be 0x20000, leaving a\np_offset gap [0x10020, 0x20000) in the output.\n\nAlternatively, if we advance the position to 0x20020, the new PT_LOAD\nwill have p_vaddr=0x20020. We can pick either 0x10020 or 0x20020 for p_offset!\nObviously 0x10020 is the choice because it leaves no gap.\nAt runtime, p_vaddr will be rounded down by pagesize\n(0x20000 if pagesize=maxPageSize). This PT_LOAD will load initial\ncontents from p_offset ranges [0x10000,0x10020), which will also be\nloaded by the previous PT_LOAD. This is fine if -z noseparate-code is in\neffect or if we are not transiting between executable and non-executable\nsegments.\n\nld.bfd leverages this technique to keep output small. This can be\nobserved with its -z noseparate-code output. This patch implements the\ntechnique in lld. With our default -z noseparate-code, it removes 2\nalignment boundaries, as indicated by `|`:\n`R | RX | RW(relro) RW(non-relro)`\n\nThis technique is mostly effective on targets with large\ndefaultMaxPageSize (AArch64/MIPS/PPC: 65536). The two alignment\nboundaries can increase the file size by almost 2*65536 bytes.\n\nA note about p_memsz of PT_GNU_RELRO: we used to round it up to\ncommonPageSize (defaults to 4096 on all targets).  Now\np_vaddr%commonPageSize may be non-zero so we need to take account of\nthat factor.\n\nFix TP offset computation of x86 and PPC.\n\n* x86: `st_value - p_memsz - (-p_vaddr-p_memsz & p_align-1)`\n* PPC: `st_value + p_vaddr%p_align - 0x7000`\n\n  p_vaddr rounded down to p_align has TP offset -0x7000.\n  The first address of PT_TLS (p_vaddr) has TP offset (p_vaddr%p_align - 0x7000).\n\nDue to the large number of tests I have to fix (offset/address changes)\nand potential risk, this technique is only enabled for PPC in this\npatch.\n\nReviewers: espindola, grimar, mcgrathr, pcc, peter.smith, phosek, ruiu\n\nSubscribers: sdardis, javed.absar, kristof.beyls, atanasyan, jsji, emaste, nemanjai, arichardson, kbarton, llvm-commits\n\nTags: #llvm\n\nDifferential Revision: https://reviews.llvm.org/D64906","distinct":true,"url":"https://api.github.com/repos/MaskRay/lld/commits/4e53e7290a19dffe181bce1bce58727023b98ea8"}]}
{"actor":{"display_login":"MaskRay"}}