Hi Frank,
thank you for your answer again. However, as you observed, your solution will not always work, i.e., in the following case it will fail:
%define ROUNDUP(a, b) (b * ((a + b - 1)/b))
base equ 0x400000
org base
start:
dd totalsize
times 2045 db 0
end:
test_align equ 0x1000
section test progbits valign=test_align align=0x200
times 2048 db 0
totalsize equ ROUNDUP(($ - $$ ) + (end - start) + test_align , 0x1000)
Here, nothing really changes with respect to section granularity. The section still starts at 0x401000 and consists of 2048 bytes, i.e., totalsize should still be 0x2000. However, it is 0x3000. The problem is that your solution uses "test_align" in the computation to compensate for the padding, which is, however, inaccurate and as far as I can tell one cannot really know the padding at this point.