Bug 30623 - objcopy --set-section-flags: support toggling a flag
Summary: objcopy --set-section-flags: support toggling a flag
Status: NEW
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-07-08 05:48 UTC by Fangrui Song
Modified: 2023-07-08 05:48 UTC (History)
0 users

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 2023-07-08 05:48:43 UTC
It will be more convenient if --set-section-flags supports toggling a flag, instead of specifying the full set of flags, e.g.

--set-section-flags .foo=-alloc
--set-section-flags .foo=-readonly
--set-section-flags .foo=+readonly

The lack of toggling flags is currently not so cumbersome because most ELF sections only use "alloc" and "readonly".
However, if we consider more flags, e.g. "exclude", "large" (https://sourceware.org/bugzilla/show_bug.cgi?id=30592), the lack of toggling flags is quite inconvenient.
For example, if we want to add SHF_X86_64_LARGE to large data sections, we need to figure out whether "readonly" is set.

--set-section-flags .ldata=alloc,large
--set-section-flags .lrodata=alloc,readonly,large

It will be more convenient if we can just use

--set-section-flags .ldata=+large
--set-section-flags .lrodata=+large

Candidate syntax: the right hand side of `=` can use one of the two forms:

* comma separated flags, e.g. alloc,large
* comma separated + flags and - flags, e.g. -alloc,+readonly

Other forms like -alloc,readonly probably should be rejected.