summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2020-08-06 16:24:16 -0700
committerElliott Hughes <enh@google.com>2020-08-06 16:24:16 -0700
commit341272d909285da90e44015ca41f956fd00b9dd8 (patch)
tree8512e874ba0dd3cd2871cc5453ccb2fca427e72d
parent0241a1304fd183ee24fbdfe6891f18fdedea38f9 (diff)
Use hidden visibility for jpeg_nbits_table.
The non-upstream change to reuse one copy of jpeg_nbits_table rather than inline it with the two assembler routines that use it causes issues when generating a shared library with lld. Specifically: movzx edx, byte [GOTOFF(ebp, jpeg_nbits_table + ecx)] causes invalid relocations for jpeg_nbits_table. Normally if the target symbol is local, both movl $1, foo@GOTOFF(%ecx) and leal foo@GOTOFF(%eax), %eax will produce a R_386_GOTOFF relocation referencing a STT_SECTION local symbol. There is no issue for GNU ld or LLD. If the target symbol is global and preemptible LLD will report an error (GNU ld permissively allows it). The fix is to make jpeg_nbits_table hidden. Bug: http://b/162610242 Bug: https://issuetracker.google.com/135180511 Change-Id: I4fe75ca0069a047db05ab18eb36e94bf535878f5
-rw-r--r--README.chromium6
-rw-r--r--jpeg_nbits_table.c4
2 files changed, 9 insertions, 1 deletions
diff --git a/README.chromium b/README.chromium
index 1831dae..c0992dd 100644
--- a/README.chromium
+++ b/README.chromium
@@ -48,7 +48,11 @@ following changes which are not merged to upstream:
in the header instead of static const and moving the definition to
a new .c file fixes this so only one copy is referenced. Also added
extern wrappers around usage in asm files. The jpeg_nbits_table.inc
- file was also deleted.
+ file was also deleted. It was also necessary to give this table hidden
+ visibility to avoid invalid relocations (ignored by ld but rejected by
+ lld) arising from attempts to reference the table from assembler on
+ 32-bit x86. This only affects shared libraries, but that's important
+ for downstream Android builds.
* Arm NEON patches to improve performance and maintainability. These changes
are tracked by the following Chromium issue: https://crbug.com/922430
- Add memory alignment size check in jmemmgr.c
diff --git a/jpeg_nbits_table.c b/jpeg_nbits_table.c
index 70fd120..afcee74 100644
--- a/jpeg_nbits_table.c
+++ b/jpeg_nbits_table.c
@@ -1,5 +1,9 @@
#include "jpeg_nbits_table.h"
+/* NOTE: Both GCC and Clang define __GNUC__ */
+#if defined __GNUC__
+__attribute__((visibility("hidden")))
+#endif
const unsigned char jpeg_nbits_table[65536] = {
0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,