aboutsummaryrefslogtreecommitdiff
path: root/stdio-common/printf-parsemb.c
diff options
context:
space:
mode:
authorCarlos Eduardo Seo <carlos.seo@arm.com>2022-07-07 18:46:43 +0000
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2022-10-27 14:46:55 +0100
commitcfa623ce10c5d1319f3a8345930a5044b3471e57 (patch)
tree68382f4197a30fe1b1e124b9a39391673c861df6 /stdio-common/printf-parsemb.c
parentc6827cd8b558a4fa191ad285bde4a17efdd758db (diff)
downloadglibc-cfa623ce10c5d1319f3a8345930a5044b3471e57.tar
glibc-cfa623ce10c5d1319f3a8345930a5044b3471e57.tar.gz
glibc-cfa623ce10c5d1319f3a8345930a5044b3471e57.tar.bz2
glibc-cfa623ce10c5d1319f3a8345930a5044b3471e57.zip
cheri: stdio-common: add support for printing CHERI capabilities
This adds a new modifier %#p for printing capability information according to the CHERI C Programming guide: https://github.com/CTSRD-CHERI/cheri-c-programming/wiki/Displaying-Capabilities A %#p option in printf will display: <address> [<permissions>,<base>-<top>] (<attr>) * address: Virtual address of capability displayed as a hexadecimal value with a 0x prefix. * permissions: Zero or more of the following characters: r: LOAD permission w: STORE permission x: EXECUTE permission R: LOAD_CAP permission W: STORE_CAP permission E: EXECUTIVE permission (Morello only) * base: Lower bound of capability displayed as a hexadecimal value with a 0x prefix. * top: Upper bound of capability plus 1 displayed as a hexadecimal value with a 0x prefix. * attr: Zero or more of the following comma-separated attributes. If none of the attributes are present, this field is omitted (along with the enclosing parentheses/brackets). invalid: Capability's tag is clear. sentry: Capability is a sealed entry. sealed: Capability is sealed with a type other than the sealed entry object type. A %p option in printf will display the capability value (address) normally.
Diffstat (limited to 'stdio-common/printf-parsemb.c')
-rw-r--r--stdio-common/printf-parsemb.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/stdio-common/printf-parsemb.c b/stdio-common/printf-parsemb.c
index 386e2a27bb..e9e395c2de 100644
--- a/stdio-common/printf-parsemb.c
+++ b/stdio-common/printf-parsemb.c
@@ -80,6 +80,7 @@ __parse_one_specmb (const UCHAR_T *format, size_t posn,
spec->info.pad = ' ';
spec->info.wide = sizeof (UCHAR_T) > 1;
spec->info.is_binary128 = 0;
+ spec->info.is_cap = 0;
/* Test for positional argument. */
if (ISDIGIT (*format))
@@ -371,6 +372,10 @@ __parse_one_specmb (const UCHAR_T *format, size_t posn,
break;
case L'p':
spec->data_arg_type = PA_POINTER;
+#ifdef __CHERI_PURE_CAPABILITY__
+ if (spec->info.alt)
+ spec->info.is_cap = 1;
+#endif
break;
case L'n':
spec->data_arg_type = PA_INT|PA_FLAG_PTR;