Skip to content

Commit

Permalink
PIE support
Browse files Browse the repository at this point in the history
Summary:
GenAI reported that walltime is not collecting python stacks in any of our profilers (walltime / Pyperf)

When looking into the issue we noticed that the Python executable being used is a PIE (Position Independent Executable)

This can be seen in the file output

```
file /proc/2809260/root/packages/xlformers_emu_conda_unified/conda/bin/python3.10
```

```
ELF 64-bit LSB **pie** executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /usr/local/fbcode/platform010//lib/ld.so, for GNU/Linux 2.6.18, with debug_info, not stripped
```

Code below handles PIE by treating it as a regular executable but handling the relocation.

We detect if this is a PIE by checking two conditions
1) type is `ET_DYN`
2) Dynamic section has the `DF_1_PIE` flag set

```
[[email protected] ~]# readelf --dynamic /proc/651059/root/packages/xlformers_multimodal_conda/conda/bin/python3.10  | grep FLAGS_1
 0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
```

More Info:
https://fburl.com/moahwrc8

Reviewed By: nslingerland

Differential Revision: D66198184

fbshipit-source-id: faf5da2476a1a81a4e2dd0a3d3cf8e4adb8c557c
  • Loading branch information
RihamSelim authored and facebook-github-bot committed Nov 22, 2024
1 parent 9b159cf commit a5443ac
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions folly/debugging/symbolizer/Elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ using ElfShdr = FOLLY_ELF_ELFW(Shdr);
using ElfSym = FOLLY_ELF_ELFW(Sym);
using ElfRel = FOLLY_ELF_ELFW(Rel);
using ElfRela = FOLLY_ELF_ELFW(Rela);
using ElfDyn = FOLLY_ELF_ELFW(Dyn);

// ElfFileId is supposed to uniquely identify any instance of an ELF binary.
// It does that by using the file's inode, dev ID, size and modification time
Expand Down

0 comments on commit a5443ac

Please sign in to comment.