Bug 24505 - Should --nmagic affect MAXPAGESIZE/COMMONPAGESIZE?
Summary: Should --nmagic affect MAXPAGESIZE/COMMONPAGESIZE?
Status: RESOLVED WONTFIX
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-30 15:59 UTC by Fangrui Song
Modified: 2019-08-15 15:12 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fangrui Song 2019-04-30 15:59:44 UTC
-n/--nmagic disables page alignment of sections. Should it affect the target specific constants MAXPAGESIZE and COMMONPAGESIZE by changing them to 1?

% cat a.lds
maxpagesize = CONSTANT(MAXPAGESIZE);
commonpagesize = CONSTANT(COMMONPAGESIZE);
% as /dev/null -o a.o
% ld.bfd -n a.o -T a.lds -o a
% readelf -Ws a | grep pagesize
     2: 0000000000001000     0 NOTYPE  GLOBAL DEFAULT  ABS commonpagesize
     3: 0000000000200000     0 NOTYPE  GLOBAL DEFAULT  ABS maxpagesize

Feel free to close the issue if CONSTANT(MAXPAGESIZE) / CONSTANT(COMMONPAGESIZE) are not supposed to change.
I just have a feeling that making commonpagesize=maxpagesize=1 may simplify the implementation.
Comment 1 Nick Clifton 2019-08-15 14:34:11 UTC
Hi Fanguri,

  It might be implied, but it certainly is not implemented or documented.

  I think that it would be best to leave things as they are.  Changing
  the behaviour now would probably break somebody's program somewhere.

Cheers
  Nick
Comment 2 Fangrui Song 2019-08-15 15:12:04 UTC
Thanks for the reply.

I've tried hard to find who are using both CONSTANT(COMMONPAGESIZE) and -n/-N in the wild.

It looks only Tianocore edk2 (ab)uses -n -z common-page-size=0x20 to use CONSTANT(COMMONPAGESIZE) as if it were a preprocessor macro set with -D in the compiler.

But not changing the behavior is also fine.