@@ -271,8 +271,6 @@ func TestElfBindNow(t *testing.T) {
271
271
}
272
272
273
273
var (
274
- gotDfBindNow , gotDf1Now , gotDf1Pie bool
275
-
276
274
dir = t .TempDir ()
277
275
src = filepath .Join (dir , fmt .Sprintf ("elf_%s.go" , test .name ))
278
276
binFile = filepath .Join (dir , test .name )
@@ -311,16 +309,25 @@ func TestElfBindNow(t *testing.T) {
311
309
t .Fatalf ("failed to get DT_FLAGS_1: %v" , err )
312
310
}
313
311
314
- if gotDfBindNow = gotDynFlag (flags , uint64 (elf .DF_BIND_NOW )); gotDfBindNow != test .wantDfBindNow {
315
- t .Fatalf ("DT_FLAGS BIND_NOW flag is %v, want: %v" , gotDfBindNow , test .wantDfBindNow )
312
+ gotDfBindNow := gotDynFlag (flags , uint64 (elf .DF_BIND_NOW ))
313
+ gotDf1Now := gotDynFlag (flags1 , uint64 (elf .DF_1_NOW ))
314
+
315
+ bindNowFlagsMatch := gotDfBindNow == test .wantDfBindNow && gotDf1Now == test .wantDf1Now
316
+
317
+ // some external linkers may set one of the two flags but not both.
318
+ if ! test .mustInternalLink {
319
+ bindNowFlagsMatch = gotDfBindNow == test .wantDfBindNow || gotDf1Now == test .wantDf1Now
316
320
}
317
321
318
- if gotDf1Now = gotDynFlag (flags1 , uint64 (elf .DF_1_NOW )); gotDf1Now != test .wantDf1Now {
319
- t .Fatalf ("DT_FLAGS_1 DF_1_NOW flag is %v, want: %v" , gotDf1Now , test .wantDf1Now )
322
+ if ! bindNowFlagsMatch {
323
+ t .Fatalf ("Dynamic flags mismatch:\n " +
324
+ "DT_FLAGS BIND_NOW got: %v, want: %v\n " +
325
+ "DT_FLAGS_1 DF_1_NOW got: %v, want: %v" ,
326
+ gotDfBindNow , test .wantDfBindNow , gotDf1Now , test .wantDf1Now )
320
327
}
321
328
322
- if gotDf1Pie = gotDynFlag (flags1 , uint64 (elf .DF_1_PIE )); gotDf1Pie != test .wantDf1Pie {
323
- t .Fatalf ("DT_FLAGS_1 DF_1_PIE flag is %v, want: %v" , gotDf1Pie , test .wantDf1Pie )
329
+ if gotDf1Pie : = gotDynFlag (flags1 , uint64 (elf .DF_1_PIE )); gotDf1Pie != test .wantDf1Pie {
330
+ t .Fatalf ("DT_FLAGS_1 DF_1_PIE got: %v, want: %v" , gotDf1Pie , test .wantDf1Pie )
324
331
}
325
332
})
326
333
}
0 commit comments