Skip to content

Expugne executable stack pattern #1

Description

@fsaad

librvg dynamically creates functions on the stack, which is a GNU extension and requires compiling with -z,execstack. This pattern should be avoided to improve portability.

librvg/generate.h

Lines 96 to 126 in eb31050

/* Make a dual distribution function. */
#define MAKE_DDF(ddf, cdf, sf) \
const double ddf##__cutoff = quantile(cdf, nextafterf(.5, 1)); \
const bool ddf##__sign = signbit(ddf##__cutoff); \
bool ddf##__abort = false; \
if(0.5 < cdf(nextafter(ddf##__cutoff, -INFINITY))) { \
fprintf(stderr, "Invalid CDF detected.\n"); \
ddf##__abort = true; \
} \
if(0.5 <= sf(ddf##__cutoff)) { \
fprintf(stderr, "Invalid SF detected.\n"); \
ddf##__abort = true; \
} \
if (ddf##__abort) { \
exit(1); \
} \
void ddf(double x, bool * d, float * q) { \
if ((x < ddf##__cutoff) \
|| ((x == ddf##__cutoff) \
&& signbit(x) \
&& !(ddf##__sign))) { \
*d = 0; \
*q = cdf(x); \
} else { \
*d = 1; \
*q = sf(x); \
} \
assert(check_ddf_val(*d, *q)); \
}
#endif

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions