[Bug binutils/31000] New: objcopy: add support for changing ELF symbol visibility

2023-10-25 Thread i at maskray dot me
https://sourceware.org/bugzilla/show_bug.cgi?id=31000

Bug ID: 31000
   Summary: objcopy: add support for changing ELF symbol
visibility
   Product: binutils
   Version: unspecified
Status: NEW
  Severity: normal
  Priority: P2
 Component: binutils
  Assignee: unassigned at sourceware dot org
  Reporter: i at maskray dot me
  Target Milestone: ---

Recently I have been dealing with a benign multiple definition related to
compiler-rt/lib/builtins and rust-lang/compiler-builtins.
I need a workaround to convert certain symbols with hidden visibility to
default visibility.
(If you are curious, see
https://discourse.llvm.org/t/relocatable-file-definitions-shared-with-dso/74391
related to an improved linker error --no-allow-shlib-undefined)

It appears that objcopy does not provide a direct way to set symbol visibility,
but I have found a workaround:

objcopy --strip-symbol __udivmodti4 --add-symbol
__udivmodti4=.text.__udivmodti4:0,weak udivmodti4.c.o

Running this command on an archive will add __udivmodti4 to every archive
member, which is not desired. So, I needed to determine which archive member
defines __udivmodti4. I ended up implementing something like this in Bazel:

"""$(AR) x --output=$(@D)/lib $(OUTS)
for o in $(@D)/lib/*.o; do
  $(NM) -gU $$o | grep -qw __udivmodti4 && $(OBJCOPY) --strip-symbol
__udivmodti4 --add-symbol __udivmodti4=.text.__udivmodti4:0,weak $$o
done
$(AR) r $(OUTS) $(@D)/lib/*.o
rm -rf $(@D)/lib"""

This is cumbersome.

Suppose you want to convert a symbol from default visibility to hidden
visibility. Unfortunately, I couldn't find a straightforward way to do it.
However, llvm-objcopy provides two extension:

# objcopy --strip-symbol __udivmodti4 --add-symbol
__udivmodti4=.text.__udivmodti4:0,weak,hidden udivmodti4.c.o # unrecognized
symbol flag `hidden'
llvm-objcopy --strip-symbol __udivmodti4 --add-symbol
__udivmodti4=.text.__udivmodti4:0,weak,hidden udivmodti4.c.o
llvm-objcopy --strip-symbol __udivmodti4 --add-symbol
__udivmodti4=.text.__udivmodti4:0,weak --new-symbol-visibility=hidden
udivmodti4.c.o

https://llvm.org/docs/CommandGuide/llvm-objcopy.html#cmdoption-llvm-objcopy-new-symbol-visibility

--new-symbol-visibility also affects `_binary_*_{start,end,size}` symbols
created by
llvm-objcopy --new-symbol-visibility hidden -I binary -B i386:x86-64 a.txt a.o

This feature request tracks these possible extensions:

* 'hidden' in --add-symbol
* --new-symbol-visibility=hidden
* An option like --set-symbol-flags that can operate on an existing symbol

-- 
You are receiving this mail because:
You are on the CC list for the bug.


Issue 63001 in oss-fuzz: binutils:fuzz_objdump_safe: Direct-leak in bfd_malloc

2023-10-25 Thread sheriffbot via monorail
Updates:
Labels: -restrict-view-commit

Comment #3 on issue 63001 by sheriffbot: binutils:fuzz_objdump_safe: 
Direct-leak in bfd_malloc
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=63001#c3

This bug has been fixed. It has been opened to the public.

- Your friendly Sheriffbot

-- 
You received this message because:
  1. You were specifically CC'd on the issue

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings

Reply to this email to add a comment.

Issue 62933 in oss-fuzz: binutils:fuzz_objcopy: Out-of-memory in fuzz_objcopy

2023-10-25 Thread sheriffbot via monorail
Updates:
Labels: -restrict-view-commit

Comment #3 on issue 62933 by sheriffbot: binutils:fuzz_objcopy: Out-of-memory 
in fuzz_objcopy
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=62933#c3

This bug has been fixed. It has been opened to the public.

- Your friendly Sheriffbot

-- 
You received this message because:
  1. You were specifically CC'd on the issue

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings

Reply to this email to add a comment.

Issue 63449 in oss-fuzz: binutils:fuzz_objdump_safe: Null-dereference READ in alpha_ecoff_get_relocated_section_contents

2023-10-25 Thread sheriffbot via monorail
Updates:
Labels: -restrict-view-commit

Comment #3 on issue 63449 by sheriffbot: binutils:fuzz_objdump_safe: 
Null-dereference READ in alpha_ecoff_get_relocated_section_contents
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=63449#c3

This bug has been fixed. It has been opened to the public.

- Your friendly Sheriffbot

-- 
You received this message because:
  1. You were specifically CC'd on the issue

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings

Reply to this email to add a comment.