Skip to content

Commit

Permalink
feat(ELF): dynamic symbols global visibility option
Browse files Browse the repository at this point in the history
  • Loading branch information
boricj committed Aug 17, 2024
1 parent 5c95bb3 commit 1486064
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public class ElfRelocatableObjectExporter extends Exporter {
private boolean generateSectionNamesStringTable;
private boolean generateSectionComment;
private boolean generateStringAndSymbolTables;
private boolean globalDynamicSymbols;
private SymbolPreference symbolNamePreference;
private boolean generateRelocationTables;
private int relocationTableFormat;
Expand Down Expand Up @@ -108,6 +109,8 @@ public class ElfRelocatableObjectExporter extends Exporter {
private static final String OPTION_GEN_STRTAB = "Generate string & symbol tables";
private static final String OPTION_PREF_SYMNAME = "Symbol name preference";
private static final String OPTION_GEN_COMMENT = "Generate .comment section";
private static final String OPTION_DYN_SYMBOLS_GLOBAL =
"Give dynamic symbols global visibility";
private static final String OPTION_GEN_REL = "Generate relocation tables";
private static final String OPTION_REL_FMT = "Relocation table format";

Expand Down Expand Up @@ -299,6 +302,7 @@ Byte.class, autodetectElfData(program)),
new Option(OPTION_GROUP_ELF_HEADER, OPTION_GEN_SHSTRTAB, true),
new Option(OPTION_GROUP_ELF_HEADER, OPTION_GEN_COMMENT, true),
new Option(OPTION_GROUP_SYMBOLS, OPTION_GEN_STRTAB, true),
new Option(OPTION_GROUP_SYMBOLS, OPTION_DYN_SYMBOLS_GLOBAL, false),
new EnumDropDownOption<>(OPTION_GROUP_SYMBOLS, OPTION_PREF_SYMNAME,
SymbolPreference.class, DEFAULT_SYMBOL_PREFERENCE),
new Option(OPTION_GROUP_RELOCATIONS, OPTION_GEN_REL, true),
Expand All @@ -320,6 +324,7 @@ public void setOptions(List<Option> options) {
OptionUtils.getOption(OPTION_GEN_SHSTRTAB, options, false);
generateSectionComment = OptionUtils.getOption(OPTION_GEN_COMMENT, options, false);
generateStringAndSymbolTables = OptionUtils.getOption(OPTION_GEN_STRTAB, options, false);
globalDynamicSymbols = OptionUtils.getOption(OPTION_DYN_SYMBOLS_GLOBAL, options, false);
symbolNamePreference =
OptionUtils.getOption(OPTION_PREF_SYMNAME, options, DEFAULT_SYMBOL_PREFERENCE);
generateRelocationTables = OptionUtils.getOption(OPTION_GEN_REL, options, false);
Expand Down Expand Up @@ -416,7 +421,7 @@ else if (obj instanceof Function) {
}

private byte determineSymbolVisibility(Symbol symbol) {
if (!symbol.isDynamic()) {
if (!symbol.isDynamic() || globalDynamicSymbols) {
return ElfSymbol.STB_GLOBAL;
}

Expand Down

0 comments on commit 1486064

Please sign in to comment.