Browse Source

termux-tools: Enable compiler warnings and fix them

android-5
Fredrik Fornwall 10 years ago
parent
commit
3ca4ba784b
  1. 2
      packages/termux-tools/build.sh
  2. 30
      packages/termux-tools/termux-elf-cleaner.cpp

2
packages/termux-tools/build.sh

@ -3,7 +3,7 @@ TERMUX_PKG_DESCRIPTION="Some tools for Termux"
TERMUX_PKG_VERSION=0.5
termux_step_make_install () {
$CXX $CFLAGS $LDFLAGS -std=c++14 $TERMUX_PKG_BUILDER_DIR/*.cpp -o $TERMUX_PREFIX/bin/termux-elf-cleaner
$CXX $CFLAGS $LDFLAGS -std=c++14 -Wall -Wextra -pedantic -Werror $TERMUX_PKG_BUILDER_DIR/*.cpp -o $TERMUX_PREFIX/bin/termux-elf-cleaner
rm -f $TERMUX_PREFIX/bin/{am,termux-user,termux-fix-shebang,termux-reload-style,chsh,termux-open-url}
cp $TERMUX_PKG_BUILDER_DIR/{am,termux-user,termux-fix-shebang,termux-reload-style,chsh,termux-open-url} $TERMUX_PREFIX/bin/

30
packages/termux-tools/termux-elf-cleaner.cpp

@ -59,24 +59,20 @@ bool process_elf(uint8_t* bytes, size_t elf_file_size)
for (unsigned int j = 0; j < dynamic_section_entries; j++) {
ElfDynamicSectionEntryType* dynamic_section_entry = dynamic_section + j;
char const* removed_name = nullptr;
switch (dynamic_section_entry->d_tag) {
case DT_VERNEEDED:
case DT_VERNEEDNUM:
case DT_RPATH:
case DT_RUNPATH:
char const* removed_name;
switch (dynamic_section_entry->d_tag) {
case DT_VERNEEDED: removed_name = "DT_VERNEEDED"; break;
case DT_VERNEEDNUM: removed_name = "DT_VERNEEDNUM"; break;
case DT_RPATH: removed_name = "DT_RPATH"; break;
case DT_RUNPATH: removed_name = "DT_RUNPATH"; break;
}
printf("Removing the %s dynamic section entry\n", removed_name);
// Tag the entry with DT_NULL and put it last:
dynamic_section_entry->d_tag = DT_NULL;
// Decrease j to process new entry index:
std::swap(dynamic_section[j--], dynamic_section[last_nonnull_entry_idx--]);
break;
case DT_VERNEEDED: removed_name = "DT_VERNEEDED"; break;
case DT_VERNEEDNUM: removed_name = "DT_VERNEEDNUM"; break;
case DT_RPATH: removed_name = "DT_RPATH"; break;
case DT_RUNPATH: removed_name = "DT_RUNPATH"; break;
}
if (removed_name != nullptr) {
printf("Removing the %s dynamic section entry\n", removed_name);
// Tag the entry with DT_NULL and put it last:
dynamic_section_entry->d_tag = DT_NULL;
// Decrease j to process new entry index:
std::swap(dynamic_section[j--], dynamic_section[last_nonnull_entry_idx--]);
break;
}
}
}

Loading…
Cancel
Save