This is an archive of the discontinued LLVM Phabricator instance.

[scudo] Allow for compile-time choice of the SizeClassMap
ClosedPublic

Authored by cryptoad on Nov 27 2017, 2:15 PM.

Details

Summary

With this change, we allow someone to chose the SizeClassMap they want to use
at compile time via a define.

I feel somewhat unimaginative with the name of the defines, so if someone has a
better idea, let me know. I have been alternating between those and
SCUDO_USE_xxx_SIZECLASSMAP which is clearer but also longer. The issue with
those is that it wouldn't be consistent with SCUDO_TSD_EXCLUSIVE that should
probably become SCUDO_USE_EXCLUSIVE_TSD maybe?

Anyway, naming is hard, and I am not sure what makes more sense!

Event Timeline

cryptoad created this revision.Nov 27 2017, 2:15 PM
alekseyshl accepted this revision.Nov 27 2017, 4:19 PM

What's wrong with SCUDO_SCM_{DEFAULT|COMPACT|VERY_COMPACT}? If someone wants to tinker with it, they probably aware what SCM stands for and what it affects.

lib/scudo/scudo_platform.h
67

Why not just fold it into #else?

This revision is now accepted and ready to land.Nov 27 2017, 4:19 PM
cryptoad added inline comments.Nov 27 2017, 5:25 PM
lib/scudo/scudo_platform.h
67

Well the train of thought was that the actual default might be different in the future so I wanted to have a separate #else there.

I guess another question that I had for you @alekseyshl : would you rather see #if or #ifdef?
I am not sure SCUDO_SCM_DEFAULT=1 makes sense as opposed to it just being defined.

I guess another question that I had for you @alekseyshl : would you rather see #if or #ifdef?
I am not sure SCUDO_SCM_DEFAULT=1 makes sense as opposed to it just being defined.

Another idea, how about defining the type name?

SCUDO_SIZE_CLASS_MAP={Default|Compact|VeryCompact}

and then do something like this:

#if !defined(SCUDO_SIZE_CLASS_MAP)
# define SCUDO_SIZE_CLASS_MAP Default
#endif

#define SIZE_CLASS_MAP_TYPE SIZE_CLASS_MAP_TYPE_(SCUDO_SIZE_CLASS_MAP)
#define SIZE_CLASS_MAP_TYPE_(T) SIZE_CLASS_MAP_TYPE__(T)
#define SIZE_CLASS_MAP_TYPE__(T) T##SizeClassMap

typedef SIZE_CLASS_MAP_TYPE SizeClassMap;
lib/scudo/scudo_platform.h
67

Default value might be different from the one Scudo defaults to in case it was not defined? Hmm...

cryptoad updated this revision to Diff 124690.Nov 28 2017, 8:14 PM
cryptoad marked 3 inline comments as done.

As per Aleksey's excellent suggestion, allow for the typename to be defined via
SCUDO_SIZE_CLASS_MAP={Default|Compact|VeryCompact}. Which makes a lot more
sense.

alekseyshl accepted this revision.Nov 29 2017, 11:39 AM
cryptoad closed this revision.Nov 29 2017, 11:52 AM