Skip to content

Commit e3f05dd

Browse files
committed
Add LFI_PREFIX_PAD for postlinker
1 parent 9b0c8b9 commit e3f05dd

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

lfi-postlink/amd64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ amd64_postlink(uint8_t* buf, size_t sz)
448448
nopfix(code, p->filesz, args.bundle, p->vaddr);
449449
while (count + args.bundle <= p->filesz) {
450450
/* bundlefix(&code[count], p->filesz - count, args.bundle, p->vaddr + count); */
451-
if (!args.noprefix && false)
451+
if (args.prefix)
452452
padrewrite(&code[count], args.bundle, p->vaddr + count);
453453
callrewrite(&code[count], args.bundle, p->vaddr + count);
454454
count += args.bundle;

lfi-postlink/main.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ static char args_doc[] = "INPUT";
1717
enum {
1818
ARG_bundle = 0x80,
1919
ARG_meter = 0x81,
20-
ARG_noprefix = 0x82,
20+
ARG_prefix = 0x82,
2121
ARG_precise = 0x83,
2222
};
2323

@@ -27,7 +27,7 @@ static struct argp_option options[] = {
2727
{ "bundle", ARG_bundle, "SIZE", 0, "set the bundle size" },
2828
{ "meter", ARG_meter, "TYPE", 0, "set the metering type (branch,fp,timer)" },
2929
{ "precise", ARG_precise, 0, 0, "enable precise metering" },
30-
{ "no-prefix-pad", ARG_noprefix, 0, 0, "disable prefix padding" },
30+
{ "prefix-pad", ARG_prefix, 0, 0, "enable prefix padding" },
3131
{ 0 },
3232
};
3333

@@ -63,8 +63,8 @@ parse_opt(int key, char* arg, struct argp_state* state)
6363
case ARG_precise:
6464
args->precise = true;
6565
break;
66-
case ARG_noprefix:
67-
args->noprefix = true;
66+
case ARG_prefix:
67+
args->prefix = true;
6868
break;
6969
case ARGP_KEY_ARG:
7070
args->input = arg;
@@ -104,6 +104,10 @@ main(int argc, char** argv)
104104
args.input = "";
105105
argp_parse(&argp, argc, argv, ARGP_NO_HELP, 0, &args);
106106

107+
const char* prefix = getenv("LFI_PREFIX_PAD");
108+
if (prefix && strcmp(prefix, "1") == 0)
109+
args.prefix = true;
110+
107111
if (strcmp(args.input, "") == 0) {
108112
fprintf(stderr, "error: no input file\n");
109113
return 1;

lfi-postlink/postlink.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct arguments {
1616
char* arch;
1717
int bundle;
1818
enum meter meter;
19-
bool noprefix;
19+
bool prefix;
2020
bool precise;
2121
};
2222

0 commit comments

Comments
 (0)