google / bloaty

Bloaty: a size profiler for binaries
Apache License 2.0
4.66k stars 337 forks source link

The order of condition judgement is illogical in bloaty::ReadEncodedPointer(eh_frame.cc). #333

Open ych opened 1 year ago

ych commented 1 year ago

In function bloaty::ReadEncodedPointer

  uint8_t format = encoding & DW_EH_PE_FORMAT_MASK;

  switch (format) {
    case DW_EH_PE_omit:

The code tries to do AND operation with DW_EH_PE_FORMAT_MASK(0xf) and tries to meet DW_EH_PE_omit(0xff), but it is not possible to happen.

I try to find some example code: https://github.com/torvalds/linux/blob/master/tools/perf/util/unwind-libunwind-local.c#L112

The code tries to compare with DW_EH_PE_omit first then do AND operation with DW_EH_PE_FORMAT_MASK.